473,238 Members | 1,819 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,238 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 1343
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...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.