Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    Conwy. UK
    Posts
    122
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    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
    An answer needs a question just as much as a question needs an answer. Deep eh!

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    United Kingdom Confused: Often
    Posts
    859
    Thanks
    0
    Thanked 0 Times in 0 Posts
    this should work (but if it wants to conform to the ways of all my other scripts it wont )

    Code:
    <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?

    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
    Last edited by redhead; 09-03-2002 at 09:53 PM.
    redhead

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    Conwy. UK
    Posts
    122
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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!
    An answer needs a question just as much as a question needs an answer. Deep eh!

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    United Kingdom Confused: Often
    Posts
    859
    Thanks
    0
    Thanked 0 Times in 0 Posts
    any time (except thursdays...)
    redhead


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •