default button? plz help

admin

Administrator
Staff member
I have two submit buttons on the same form. I'd like to make the second the default button, the one that is clicked when the user presses enter. Is this possible and if so how do i do it?<br />
<br />
Thanks in advance<!--content-->why are you using 2 submit buttons?<!--content-->test.pcllca.net/header.php<br />
<br />
I decided to be slick making this payment center... take a look and youll see. Still lookin for the answer though...<!--content-->you don't need two submit buttons. make the forward button a submit button, make the back button a regular button that uses javascript to go back.<br />
<br />
<input name="back" type="button" onclick="document.history.go(-1)"><br />
<br />
I believe that will work.<!--content-->I thought of that, but heres the problem. User gets to step 3, but realizes they want to make a change on step 1. They click back to step 1, make a change, then click next. All the stuff they did on step 2 and 3 are now lost. Thats why when they go back it needs to be submitted because all options and values are stored as hidden fields so that they carry across<!--content-->even if you did it the way you have it will be the samething. the way you have it they will still have to go back and then push submit to go forward. it will still submit the form to go to step 2 which they have to fill all over again.<br />
<br />
you cannot go back without submitting it again. if you want to use 2 submit buttons you need to use to forms. even if the second form is just a submit button.<!--content-->Creating two seperate forms will not work, unless there is a way that two different forms can share the same fields. take the following code for example:<br />
<br />
<html> <br />
<head><br />
<title><br />
</title> <br />
</head> <br />
<body> <br />
<form name="blah" method="post" action="this.php"> <br />
<input type="hidden" name="val" value="yes"> <br />
<input type="submit" value="submit1"> <br />
</form> <br />
<form name="blah" method="post" action="this.php"> <br />
<input type="submit" value="submit2"> <br />
</form> <br />
<? echo $_POST[val]; ?> <br />
</body> <br />
</html> <br />
<br />
Submitting with the second button does not post the values from the first form.<!--content-->a submit button can't submit another forms fields.<br />
<br />
you can't overlap them, each form will be seperate so you have have whatever you want in them. the submit button will only submit that forms action, nothing more.<br />
<br />
still is better to have the back button as javascript as you will find it easier for you and the user.<br />
<br />
how are you going to go to setp 1 if they are on step 3? if they press back it will go to step 2 then they hit back again to goto step1 while submitting step 2 and then once at step 1 they submit just to get to step2 again and submit that one to get back to step 3 where they left off. so just to get to step 1 they have to submit 3 forms just to get back to where they were to start with. that is all redundant and you shouldn't do it that way.<!--content-->The way i have it set up works and it works well, you dont fully understand how im doing things. while the form submits to header.php?step=(current step + 1), when the submit button is pressed it submits its own value<br />
<br />
if(!empty($_POST[next]))<br />
$go = 1;<br />
elseif(!empty($_POST[back]))<br />
$go = -2;<br />
else <br />
$go = 0;<br />
<br />
<br />
header.php takes care of the content that is loaded, which is for example: include ("step" . ($_GET[step] + $go) . ".php")<br />
<br />
Using javascript back wont take post vars from step 3 and carry them back to step 1. My way does.<!--content-->ok that is understandable. bu twhy would you want to take step3 varaibles back to #1. not is the part that is not needed. if they start out they don't have step 3 varaibles so why take them back with the user. it seems you are creating more work for yourself than you have to.<!--content-->
 
Back
Top