More than one submit to set a redirect variable with PHP

J

JS

I have a series of pages which make up a questionnaire. It's all done
in PHP and I'd like to have two submit buttons (well, images really) so
that one submits the form and takes them to the next page, the other
submits the form and takes them to the previous page.

The redirect value is set using PHP so I'd like some Javascript to set
that variable, then submit the form so that I can accomplish this
requirement.

Is this possible? I know Javascript can submit a form, and also can
send a variable to a PHP script, but I'm not sure how to do this
combination.

Thanks in advance.

Jon
 
R

RobB

JS said:
I have a series of pages which make up a questionnaire. It's all done
in PHP and I'd like to have two submit buttons (well, images really) so
that one submits the form and takes them to the next page, the other
submits the form and takes them to the previous page.

The redirect value is set using PHP so I'd like some Javascript to set
that variable, then submit the form so that I can accomplish this
requirement.

Is this possible? I know Javascript can submit a form, and also can
send a variable to a PHP script, but I'm not sure how to do this
combination.

Thanks in advance.

Jon

Just use two graphical submit 'buttons':

<input type="image" src="..." name="back" value="true" />
<input type="image" src="..." name="fwd" value="true" />

Be aware that when you fish that element name out at the server it'll
be in the format:

back.x [or] back.y

....as the clickpoint is sent along, kind of a $0.98 image map. Gecko
posts the name/value pair by itself as well.
 
J

JS

Excellent, very fast response. Many thanks, I'll give your tips a go
and let you know how I get on.
 
J

JS

Hi again

Couldn't get micha's suggestion to work but managed to modify it
successfully:

javascript:document.form1.redirect_page.value='page04.php';document.form1.submit();

It's working fine in IE6. Have I breached any rules that could cause
problems?

Thanks again.
 
R

RobB

JS said:
Hi again

Couldn't get micha's suggestion to work but managed to modify it
successfully:

javascript:document.form1.redirect_page.value='page04.php';document.form1.submit();

It's working fine in IE6. Have I breached any rules that could cause
problems?

Yes. Never submit a form programmatically - with JavaScript - if you
can help it. No JS, no form.
 
J

JS

Thanks RobB. I do have a standard submit button at the bottom of the
form too which just takes you to the next page so I guess having the JS
for Prev...Next isn't such a problem. I'm intrigued by your solution
with the image buttons but am unclear how to actually implement it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top