PDA

View Full Version : Form submission with 2 buttons that alter value of a hidden field. Is this possible?


Jeepers
09-03-2002, 08:39 PM
Hi Guys an Gals

Here we go. I have a form that is called by a perl script. By using hidden input fields in the form I control the script.

On the form there will be a 2 graphic 'buttons' to either submit and call the form again or to submit and then go elsewhere, it is the choice of the user.

My query is, how can I alter the value of a hidden field to say 1 when the 'lets call the form again' button is clicked and to say 2 when the 'I don't want to call it again' button is clicked or any other way of letting the script know which button was clicked.

I'm probably missing something really obvious like there is a way collecting the clicked button name from the environment variables, but hey Idon't know???

I thought about a using document.write to create a new hidden field with the value i want but I think that that would dump the page and write a new one because it would be done after the page has been initialy written.

I'm a little bit stumped any one with any ideas. Ta chuck

redhead
09-03-2002, 08:48 PM
this should work (but if it wants to conform to the ways of all my other scripts it wont ;))

<script>
function callAgain() {
document.formName.hiddenName.value = "1";
document.formName.submit();
}
function dontCallAgain() {
document.formName.hiddenName.value = "2";
document.formName.submit();
}
</script>

<form name="formName">
... (you know the drill...)
<input type="hidden" name="hiddenName" value="0">

<input type="button" onclick="callAgain()" value="Call Again">
<input type="button onclick="dontCallAgain()" vaue="Dont Call Again">

</form>


does that help? :cool:

edit: if ur using imgs then <img whatnot="indeed" onclick="callAgain()"> and everything would be more like it instead of the buttons

edit="2" or maybe ive got completely the wrong idea

Jeepers
09-03-2002, 09:03 PM
Spot on, now why didn'y I think of that? it must be because I'm getting older and my brain is shrinking. Thanks redhead, making the impossible possible!

redhead
09-03-2002, 09:24 PM
any time :thumbsup: (except thursdays...)