471,338 Members | 1,044 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,338 software developers and data experts.

JS/Function to redirect page - Revisited

Hi all,

Just trying to direct the browser to a results page depending on the option
chosen by the user from the drop down box
'cboType' as in the code below. How to complete the function code
(especially the 'els.action' line) to check which option
was selected so the appropriate page will be targeted when the user clicks
the 'Search' button? Thanks Rob and Randell so far
but don't want to use radio buttons. I understand server side processing is
superior but surely a little function should
be able to do the job easily!

Penny.

<html>
<head>
<title>untitled</title>
<script type="text/javascript">

function directSearch(objForm){
var els = objForm.elements

els.action = ['artistresults1.asp','titleresults1.asp'];
return true;
}

<Form name="frmSearch" method="get" action="artistresults1.asp">

<SELECT name=cboType class=formfield id="cboType">
<option value="artist" selected>Artist </option>
<option value="title">Title </option>
</SELECT>

<input name="txtKeywords" type="text" class="formfield" id="txtKeywords"
value="" size="60" height="17">
<input name="btnSearch" type="submit" id="btnSearch"
onClick="MM_callJS('directSearch(this)')" value="Search">

</Form>
</body>
</html>
Jul 23 '05 #1
2 1290
Penny wrote:
Hi all,

Just trying to direct the browser to a results page depending on the option chosen by the user from the drop down box
'cboType' as in the code below. How to complete the function code
(especially the 'els.action' line) to check which option
was selected so the appropriate page will be targeted when the user clicks the 'Search' button? Thanks Rob and Randell so far
but don't want to use radio buttons. I understand server side processing is superior but surely a little function should
be able to do the job easily!

Penny.

<html>
<head>
<title>untitled</title>
<script type="text/javascript">

function directSearch(objForm){
var els = objForm.elements

els.action = ['artistresults1.asp','titleresults1.asp'];
return true;
}

<Form name="frmSearch" method="get" action="artistresults1.asp">

<SELECT name=cboType class=formfield id="cboType">
<option value="artist" selected>Artist </option>
<option value="title">Title </option>
</SELECT>

<input name="txtKeywords" type="text" class="formfield" id="txtKeywords" value="" size="60" height="17">
<input name="btnSearch" type="submit" id="btnSearch"
onClick="MM_callJS('directSearch(this)')" value="Search">

</Form>
</body>
</html>


<html>
<head>
<title>untitled</title>
<script type="text/javascript">

function directSearch(f)
{
var els = f.elements,
t = els.txtKeywords,
s = els.cboType;
if (/^\s*$/.test(t.value))
{
alert('Please enter a keyword.');
t.focus();
return false;
}
else
{
f.action =
['artistresults1.asp','titleresults1.asp'][s.selectedIndex];
return true;
}
}

</script>
</head>
<body>
<form name="frmSearch"
action="artistresults1.asp"
method="get"
onsubmit="return directSearch(this)">
<select class="formfield" name="cboType">
<option value="artist" selected="selected">Artist </option>
<option value="title">Title </option>
</select>
<input class="formfield"
type="text"
name="txtKeywords" value=""
size="60">
<input type="submit" name="btnSearch" value="Search">
</form>
</body>
</html>

Jul 23 '05 #2
Thanks Rob,

All your help eventually sorted me right out.

Penny.
"RobB" <fe******@hotmail.com> wrote in message
news:11**********************@c13g2000cwb.googlegr oups.com...
Penny wrote:
Hi all,

Just trying to direct the browser to a results page depending on the

option
chosen by the user from the drop down box
'cboType' as in the code below. How to complete the function code
(especially the 'els.action' line) to check which option
was selected so the appropriate page will be targeted when the user

clicks
the 'Search' button? Thanks Rob and Randell so far
but don't want to use radio buttons. I understand server side

processing is
superior but surely a little function should
be able to do the job easily!

Penny.

<html>
<head>
<title>untitled</title>
<script type="text/javascript">

function directSearch(objForm){
var els = objForm.elements

els.action = ['artistresults1.asp','titleresults1.asp'];
return true;
}

<Form name="frmSearch" method="get" action="artistresults1.asp">

<SELECT name=cboType class=formfield id="cboType">
<option value="artist" selected>Artist </option>
<option value="title">Title </option>
</SELECT>

<input name="txtKeywords" type="text" class="formfield"

id="txtKeywords"
value="" size="60" height="17">
<input name="btnSearch" type="submit" id="btnSearch"
onClick="MM_callJS('directSearch(this)')" value="Search">

</Form>
</body>
</html>


<html>
<head>
<title>untitled</title>
<script type="text/javascript">

function directSearch(f)
{
var els = f.elements,
t = els.txtKeywords,
s = els.cboType;
if (/^\s*$/.test(t.value))
{
alert('Please enter a keyword.');
t.focus();
return false;
}
else
{
f.action =
['artistresults1.asp','titleresults1.asp'][s.selectedIndex];
return true;
}
}

</script>
</head>
<body>
<form name="frmSearch"
action="artistresults1.asp"
method="get"
onsubmit="return directSearch(this)">
<select class="formfield" name="cboType">
<option value="artist" selected="selected">Artist </option>
<option value="title">Title </option>
</select>
<input class="formfield"
type="text"
name="txtKeywords" value=""
size="60">
<input type="submit" name="btnSearch" value="Search">
</form>
</body>
</html>

Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Bob Murdoch | last post: by
2 posts views Thread by Kenneth | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.