Click to See Complete Forum and Search --> : Controlling form action via radio buttons


viperpurple
05-23-2005, 03:19 AM
Hey Peeps,

I have a small form with a text box which i am using to call a database report via the 'GET' method. I have two search criteria that i want the user to be able to use depending on which radio button is selected.

Radio1 - Sales Order
action="sales_order_report.php"

Radio2 - Job Number
action="job_report.php"

So i need to control the form action depending on which radio button is selected.

Hope you can help :-)

viperpurple
05-23-2005, 08:32 AM
Hey,

I've actually figured it out myself now :-), i thought i'd put thi son for anyone who searches with a similiar problem though.

<form action="http://porter/reports/sales-orderquery2.php" name="search" target="mainframe" method="get" onSubmit="return search2();">
<span class=whitelink>Search:</span>
<input type="text" name="search_val" size=10>
<input type="radio" name="field" checked><span class=white>Sales Order<br>
<input type="radio" name="field">Job Number</span><br>
</form>

function search2()
{
if(document.search.field[0].checked == true)
{
document.search.search_val.name = 'SalesOrder';
document.search.action = 'http://porter/reports/sales-orderquery2.php';
document.search.method = 'get';
}

if(document.search.field[1].checked == true)
{
document.search.search_val.name = 'Job';
document.search.action = 'http://porter/reports/jobquery.php';
document.search.method = 'get';
}


return true;
}