LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   found with button was clicked (https://www.linuxquestions.org/questions/programming-9/found-with-button-was-clicked-337662/)

djgerbavore 06-27-2005 11:03 AM

found with button was clicked
 
hey,
i want to be able to know which button was clicked before i send the form, for example
Code:

<script>
function confirm() {
  /* need to know which button was click, before i send the form */
}
</script>
<form name='myform.php' onsubmit=return 'confirm()'>

<input type='submit' value='one'>
<input type='submit' value='two'>
<input type='submit' value='three'>

</form>


thanks,

djgerbavor3

keefaz 06-29-2005 03:25 AM

Not tested, but you could try add a global variable like :
Code:

<script>
currentButton = '';

function update_current(but) {
    currentButton = but;
}
function confirm() {
    alert('Button clicked: '+currentButton);
  /* need to know which button was click, before i send the form */
}
</script>
<form name='myform.php' onsubmit=return 'confirm()'>

<input type="submit" value="one" onclick="update_current('one');">
<input type="submit" value="two" onclick="update_current('two');">
<input type="submit" value="three" onclick="update_current('three');">

</form>


djgerbavore 06-29-2005 09:35 AM

Thanks for your reply, i did something similar to what you did and it work, thanks for you help


djgerbavor3


All times are GMT -5. The time now is 06:30 AM.