|
Posted by Jerry Stuckle on 11/15/07 13:51
paul814@excite.com wrote:
> Is it possible in PHP to do the following?
>
> I've got a php page with a form, that form has radio buttons group and
> an option group list. It also have a button, Continue.
>
> When the continue button is presed I want it to look at: this:
> If Radiobutton1 is pressed and option group lsteditorial is selected,
> goto write-editorial.php
> if Radiobutton1 is pressed and option group lstpres is selected, goto
> write-press.php
>
> and etc... for other combinations, so based on the selections of the
> radio buttons and option groups goto a specific page:
>
> here is my code:
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
> www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml">
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
> <title>Production Report</title><style type="text/css">
> <!--
> .style2 {font-size: 24px}
> .style5 {font-size: 18px}
> -->
> </style></head>
>
> <body>
> <center>
> <p><img src="http://info/test/etnlogored2.gif" width="199"
> height="30" /></p>
> <p> </p>
> <p><em><strong><span class="style2 style5">What would you like to
> do?:</span></strong></em></p>
> <form id="form1" name="form1" method="post" action="select.php">
> <p>
> <label>
> <input type="radio" name="radReadWrite" value="1"
> id="radReadWrite_0" />
> <span class="style5">Write Report</span></label>
> <br />
> <label>
> <input type="radio" name="radReadWrite" value="2"
> id="radReadWrite_1" />
> <span class="style5">View Report</span></label>
> </p>
> <p><em><strong><span class="style5">Please also select the
> department:</span></strong></em></p>
> <p>
> <select name="lstdepartment" id="lstdepartment">
> <option value="lstEditorial">Editorial</option>
> <option value="lstPrepress">Pre Press</option>
> <option value="lstInformationTechnology">Information
> Technology</option>
> <option value="lstPres">Press</option>
> <option value="lstMailroom">Mail Room</option>
> <option value="lstCirculation">Circulation</option>
> </select>
> </p>
> <p>
> <input type="submit" name="btnSubmit" id="btnSubmit"
> value="Continue" />
> <br />
> </p>
> </form>
> </center>
> </body>
> </html>
>
> thanks for any help as to the code or where to put it so it works with
> the button.
>
Paul,
The first thing to remember is that PHP code is all executed before the
page is sent to the browser. You have no direct interaction with the
PHP code; all you can do is submit HTML requests (i.e. GET, POST) to the
server and have that execute the code.
So, with this in mind, in your select.php (the target for your form),
your $_POST array will have an element with the index 'radReadWrite' (if
a button is selected). This will contain 1 or 2, depending on the radio
button selected.
It will also contain an element with the index 'lstdepartment' for your
SELECT box, and value of the element will be the value of the option.
Based on these values, determine which page you want to go to, and use
the header() function to redirect the browser to the page you wish.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Navigation:
[Reply to this message]
|