/    Sign up×
Community /Pin to ProfileBookmark

Controlling form action via radio buttons

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 🙂

to post a comment
HTML

1 Comments(s)

Copy linkTweet thisAlerts:
@viperpurpleauthorMay 23.2005 — 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.

[code=html] <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>[/code]


[CODE]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;
}[/CODE]
×

Success!

Help @viperpurple spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...