S
Steven Bethard
I have a form with three submit buttons, each of which posts a
different value for my "label" parameter. I'm trying to add keyboard
shortcuts so that you can also perform each type of submit using a
single key stroke. However, I'm finding that when I set the "label"
value and then call "submit()", I'm not seeing anything passed to my
CGI script.
I discovered that if I remove the "name" attributes from the submit
buttons and add a hidden input with the name "label", my Javascript
submit() code then works properly. But then the submit buttons no
longer work because they no longer have the necessary "name"
attribute.
What's the right way to go about this?
Here's the code I have currently:
<script type="text/javascript">
function add_label(event)
{
if (!event)
var event = window.event;
if (event.keyCode)
code = event.keyCode;
else if (event.which)
code = event.which;
var character = String.fromCharCode(code);
if (character == "B") {
document.label_form.label.value = "BEFORE";
document.label_form.submit();
}
if (character == "O") {
document.label_form.label.value = "OVERLAP";
document.label_form.submit();
}
if (character == "A") {
document.label_form.label.value = "AFTER";
document.label_form.submit();
}
}
document.onkeyup=add_label;
</script>
....
<form action="label/" name="label_form" method="post">
<input type="submit" name="label" value="BEFORE" />
<input type="submit" name="label" value="OVERLAP" />
<input type="submit" name="label" value="AFTER" />
</form>
different value for my "label" parameter. I'm trying to add keyboard
shortcuts so that you can also perform each type of submit using a
single key stroke. However, I'm finding that when I set the "label"
value and then call "submit()", I'm not seeing anything passed to my
CGI script.
I discovered that if I remove the "name" attributes from the submit
buttons and add a hidden input with the name "label", my Javascript
submit() code then works properly. But then the submit buttons no
longer work because they no longer have the necessary "name"
attribute.
What's the right way to go about this?
Here's the code I have currently:
<script type="text/javascript">
function add_label(event)
{
if (!event)
var event = window.event;
if (event.keyCode)
code = event.keyCode;
else if (event.which)
code = event.which;
var character = String.fromCharCode(code);
if (character == "B") {
document.label_form.label.value = "BEFORE";
document.label_form.submit();
}
if (character == "O") {
document.label_form.label.value = "OVERLAP";
document.label_form.submit();
}
if (character == "A") {
document.label_form.label.value = "AFTER";
document.label_form.submit();
}
}
document.onkeyup=add_label;
</script>
....
<form action="label/" name="label_form" method="post">
<input type="submit" name="label" value="BEFORE" />
<input type="submit" name="label" value="OVERLAP" />
<input type="submit" name="label" value="AFTER" />
</form>