|
-
Aug 1st, 2002, 09:28 PM
#1
Thread Starter
Stuck in the 80s
Two buttons
How can I do something like this:
Code:
<form>
Do you want to delete blah?<br>
<input type="submit" value=" Yes "><input type="submit" value=" No ">
</form>
So that I can have two buttons that submit the for, but each has a differen't value?
-
Aug 2nd, 2002, 05:32 AM
#2
Fanatic Member
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>
-
Aug 2nd, 2002, 10:53 AM
#3
Thread Starter
Stuck in the 80s
hmm...it'll work for now Thanks
-
Aug 2nd, 2002, 01:59 PM
#4
Frenzied Member
you could do somehting like this
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>
then in your page.php just check for the variable.
-
Aug 2nd, 2002, 02:54 PM
#5
Thread Starter
Stuck in the 80s
Wont the yes and no variables both show up no matter which one you press?
-
Aug 2nd, 2002, 02:55 PM
#6
Fanatic Member
no. it acts just like a checkbox, it only shows up if it were picked
-
Aug 2nd, 2002, 02:57 PM
#7
Frenzied Member
no because the name of each button is what determines the variable. if yes button is not pressed how can the variable get sent?
-
Aug 2nd, 2002, 02:59 PM
#8
Thread Starter
Stuck in the 80s
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?
Because it is part of the form and has a value set to it (is what I was thinking)
Thans Matt and phpman.
-
Aug 5th, 2002, 08:57 PM
#9
Thread Starter
Stuck in the 80s
It doesn't work... 
I have
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>
For the form, and:
Code:
if (isset($_REQUEST['no'])) {
} else {
}
To check. However, it always goes to the else. It never says 'no' was set?
-
Aug 5th, 2002, 09:18 PM
#10
Frenzied Member
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
-
Aug 5th, 2002, 10:20 PM
#11
Thread Starter
Stuck in the 80s
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
What does a form name matter? I never put a name on them and it works fine.
$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.
-
Aug 5th, 2002, 10:25 PM
#12
Frenzied Member
I thought you just said it wasn't working?
-
Aug 5th, 2002, 11:33 PM
#13
Thread Starter
Stuck in the 80s
Originally posted by phpman
I thought you just said it wasn't working?
It isn't. I said that forms work without the name property.
-
Aug 6th, 2002, 07:37 AM
#14
Frenzied Member
if you notice I change the onclick to work from a forms name. just to see if that was the problem.
-
Aug 6th, 2002, 11:07 AM
#15
Thread Starter
Stuck in the 80s
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.
Still no dice.
If I do this:
Code:
echo "Yes: \"" . $_REQUEST['yes'] . "\"<br>";
echo "No: \"" . $_REQUEST['no'] . "\"<br>";
I get:
No matter what button I push. Have you tried doing this on your own to see if it works?
-
Aug 6th, 2002, 12:23 PM
#16
Frenzied Member
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.
-
Aug 6th, 2002, 01:33 PM
#17
Thread Starter
Stuck in the 80s
It's cool. Thanks for all your help.
For now, I'm just going to have one of the buttons do history.back();
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|