How can I do something like this:
So that I can have two buttons that submit the for, but each has a differen't value?Code:<form> Do you want to delete blah?<br> <input type="submit" value=" Yes "><input type="submit" value=" No "> </form>
How can I do something like this:
So that I can have two buttons that submit the for, but each has a differen't value?Code:<form> Do you want to delete blah?<br> <input type="submit" value=" Yes "><input type="submit" value=" No "> </form>
I would think you could but I normally do this:
PHP Code:<form action="?" method="post">
<input type="hidden" name="action" value="delete" />
<input type="hidden" name="id" value="<?php echo $_REQUEST['id']; ?>" />
Do you want to delete blah?<br>
<input type="submit" value=" Yes "><input type="button" value=" No " onClick="history.back();">
</form>
hmm...it'll work for nowThanks
you could do somehting like this
then in your page.php just check for the variable.Code:<form action="page.php" method="post"> Do you want to delete blah?<br> <input type="button" value=" Yes " name="yes" onClick="this.document.submit();"> <input type="button" value=" No " name="no" onClick="this.document.submit();"> </form>
Wont the yes and no variables both show up no matter which one you press?
no. it acts just like a checkbox, it only shows up if it were picked
no because the name of each button is what determines the variable. if yes button is not pressed how can the variable get sent?
Because it is part of the form and has a value set to it (is what I was thinking)Originally posted by phpman
no because the name of each button is what determines the variable. if yes button is not pressed how can the variable get sent?
Thans Matt and phpman.
It doesn't work...
I have
For the form, and:Code:<div align="center"> <form action="' . $CONIFG["scripturl"] . '" method="post"> <input type="hidden" name="action" value="removeuser"> <input type="hidden" name="id" value="' . $_REQUEST['user'] . '"> Are you sure you want to remove user <b>' . $user["usn"] . '</b>?<br><br> <input type="button" name="yes" value=" Yes " onClick="document.forms(0).submit();"> <input type="button" name="no" value=" No " onClick="document.forms(0).submit();"> </form> </div>
To check. However, it always goes to the else. It never says 'no' was set?Code:if (isset($_REQUEST['no'])) { } else { }![]()
you could put a name in your form and try this
<form action="' . $CONIFG["scripturl"] . '" method="post" name="form1">
<input type="button" name="yes" value=" Yes " onClick="document.form1.submit();">
<input type="button" name="no" value=" No " onClick="document.form1.submit();">
also is $CONFIG[] coming out ok as the script name?
how do you know it goes to the else if there is nothing in either one![]()
What does a form name matter? I never put a name on them and it works fine.Originally posted by phpman
you could put a name in your form and try this
<form action="' . $CONIFG["scripturl"] . '" method="post" name="form1">
<input type="button" name="yes" value=" Yes " onClick="document.form1.submit();">
<input type="button" name="no" value=" No " onClick="document.form1.submit();">
also is $CONFIG[] coming out ok as the script name?
how do you know it goes to the else if there is nothing in either one![]()
$CONFIG[] is working fine.
and their is code in both of them, it was just rather lengthy.![]()
I guess I'll have to do this another way. Thanks for your help.
I thought you just said it wasn't working?![]()
It isn't. I said that forms work without the name property.Originally posted by phpman
I thought you just said it wasn't working?![]()
if you notice I change the onclick to work from a forms name. just to see if that was the problem.
Still no dice.Originally posted by phpman
if you notice I change the onclick to work from a forms name. just to see if that was the problem.
If I do this:
I get:Code:echo "Yes: \"" . $_REQUEST['yes'] . "\"<br>"; echo "No: \"" . $_REQUEST['no'] . "\"<br>";
No matter what button I push.Yes: ""
No: ""Have you tried doing this on your own to see if it works?
sorry Hobo, I couldn't get it to work either. in theory it should work. but you can use 2 submits.
<input type="submit" name="yes" value=" Yes " >
<input type="submit" name="no" value=" No " >
my appologies.
It's cool. Thanks for all your help.
For now, I'm just going to have one of the buttons do history.back();