473,386 Members | 1,804 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 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 1344
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Pete | last post by:
I have a site which is using sessions to pass data from one page through to the next. The problem that I have is that there are only two places where the session could/should be destroyed. This...
4
by: Bob Murdoch | last post by:
I have an ASP application that calls a COM function to create a custom report as an Excel file. This works in a synchronous fashion, as long as the report does not take too long to create. If...
35
by: wired | last post by:
Hi, I've just taught myself C++, so I haven't learnt much about style or the like from any single source, and I'm quite styleless as a result. But at the same time, I really want nice code and I...
2
by: shree | last post by:
Hi all, I'm trying to call javascript function via onLoad but running into a problem. I would appreciate any help and suggestion. My application is as follows. When a page loads, I want to check...
2
by: Kenneth | last post by:
Hi, In a document I have three lines that detects and redirects to another page is a session variable is 0 If Session("Customer_ID")=0 Then Response.Redirect("myPage.aspx") End If What I...
5
by: bienwell | last post by:
Hi all, I have a problem with using myCommand.ExecuteScalar(). My question is : If the Web setup is incorrect, does it make command ExecuteScalar() work improperly ?? In my program, I was...
1
by: Alan Silver | last post by:
Hello, I have a page where site owners can see orders placed on their site. The path to this page is /dap/order.aspx, but for security reasons (as they will end up printing these pages and...
13
by: Stephen Kay | last post by:
Is there a way to redirect every single page on an existing web site through a php function? In other words, say I have a whole functional HTML web site, never written to use any php. Now I...
1
by: john20 | last post by:
Hi All, I am having a problem with accesing function in the page. i have a page say user.aspx in the page load method i am calling function to validate the user. it works fine when single...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.