JavaScript Help Needed

P

pfldparkdistrict

I need help customizing javascript for a drop-down box (text needing
customization appears below). Here's what I want to do: when someone selects
an option in my drop-down box, they are directed to the correct page. When
they click "back" and go to the previous page, I want the drop-down box
selection to reset to the default option ("Go to a Division Page").
Currently, when someone clicks "back", they see the option they selected in
the drop-down box.

Here's the html for my drop-down box:

<form onsubmit="return FrontPage_Form1_Validator(this)"
language="JavaScript" name="FrontPage_Form1"><p style="margin-bottom:
-20"><font size="2"><nobr>
<!--webbot bot="Validation" s-display-name="Division Page Choice"
b-disallow-first-item="TRUE" --><select name="section" size="1"
language="javascript" onChange="gotoPage(this.selectedIndex);">
<option selected value="Go to a Division page">Go to a Division
page</option>
<option>- - - - - - - - - - - - - - - - -</option>
<option>Building Division</option>
<option>Code Enforcement Division</option>
<option>Historic Preservation Commission</option>
<option>Planning & Zoning Commission</option>
<option>Planning Division</option>
<option>Waste Services Division</option>
<option>Zoning Division</option>
</select></font></nobr></p></form>
<script language="JavaScript">
<!--
function gotoPage(varItem)
{
switch(varItem)
{
case 0:
window.parent.self.status="Goes Nowhere";
break;
case 1:
window.parent.self.status="Goes Nowhere";
break;
case 2:
window.location="Building/BuildMain.html";
break;
case 3:
window.location="Code/CodeMain.html";
break;
case 4:
window.location="HPC/HPCMain.html";
break;
case 5:
window.location="PZC/PZCMain.html";
break;
case 6:
window.location="Planning/PlanMain.html";
break;
case 7:
window.location="WasteServ/WasteMain.html";
break;
case 8:
window.location="Zoning/ZoningMain.html";
break;
}
}
// -->
</script>

What do I have to change?

Thanks in advance.
 
K

Kevin Spencer

Add this script at the bottom of the form:

<script type=text/javascript"><!--
document.forms[0].section.SelectedIndex = 0;
// --></script>

It will execute precisely ONE time whenever the page loads.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
 
P

pfldparkdistrict

Sorry, but I'm unsure exactly where to put that script.

Should it go before the </form> tag, after the </form> tag but before the
<script language> tag, before the </script> tag, or after the </script> tag?

Thanks!

Kevin Spencer said:
Add this script at the bottom of the form:

<script type=text/javascript"><!--
document.forms[0].section.SelectedIndex = 0;
// --></script>

It will execute precisely ONE time whenever the page loads.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

pfldparkdistrict said:
I need help customizing javascript for a drop-down box (text needing
customization appears below). Here's what I want to do: when someone
selects
an option in my drop-down box, they are directed to the correct page.
When
they click "back" and go to the previous page, I want the drop-down box
selection to reset to the default option ("Go to a Division Page").
Currently, when someone clicks "back", they see the option they selected
in
the drop-down box.

Here's the html for my drop-down box:

<form onsubmit="return FrontPage_Form1_Validator(this)"
language="JavaScript" name="FrontPage_Form1"><p style="margin-bottom:
-20"><font size="2"><nobr>
<!--webbot bot="Validation" s-display-name="Division Page Choice"
b-disallow-first-item="TRUE" --><select name="section" size="1"
language="javascript" onChange="gotoPage(this.selectedIndex);">
<option selected value="Go to a Division page">Go to a Division
page</option>
<option>- - - - - - - - - - - - - - - - -</option>
<option>Building Division</option>
<option>Code Enforcement Division</option>
<option>Historic Preservation Commission</option>
<option>Planning & Zoning Commission</option>
<option>Planning Division</option>
<option>Waste Services Division</option>
<option>Zoning Division</option>
</select></font></nobr></p></form>
<script language="JavaScript">
<!--
function gotoPage(varItem)
{
switch(varItem)
{
case 0:
window.parent.self.status="Goes Nowhere";
break;
case 1:
window.parent.self.status="Goes Nowhere";
break;
case 2:
window.location="Building/BuildMain.html";
break;
case 3:
window.location="Code/CodeMain.html";
break;
case 4:
window.location="HPC/HPCMain.html";
break;
case 5:
window.location="PZC/PZCMain.html";
break;
case 6:
window.location="Planning/PlanMain.html";
break;
case 7:
window.location="WasteServ/WasteMain.html";
break;
case 8:
window.location="Zoning/ZoningMain.html";
break;
}
}
// -->
</script>

What do I have to change?

Thanks in advance.
 
J

Jon Spivey

Hi,
Right before the </body> tag would be the easiest place
so you'd have
<body>
.....your HTML
<script type="text/javascript">
document.forms[0].section.SelectedIndex = 0;
</script>
</body>

--
Cheers,
Jon
Microsoft MVP


pfldparkdistrict said:
Sorry, but I'm unsure exactly where to put that script.

Should it go before the </form> tag, after the </form> tag but before the
<script language> tag, before the </script> tag, or after the </script>
tag?

Thanks!

Kevin Spencer said:
Add this script at the bottom of the form:

<script type=text/javascript"><!--
document.forms[0].section.SelectedIndex = 0;
// --></script>

It will execute precisely ONE time whenever the page loads.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

pfldparkdistrict said:
I need help customizing javascript for a drop-down box (text needing
customization appears below). Here's what I want to do: when someone
selects
an option in my drop-down box, they are directed to the correct page.
When
they click "back" and go to the previous page, I want the drop-down box
selection to reset to the default option ("Go to a Division Page").
Currently, when someone clicks "back", they see the option they
selected
in
the drop-down box.

Here's the html for my drop-down box:

<form onsubmit="return FrontPage_Form1_Validator(this)"
language="JavaScript" name="FrontPage_Form1"><p style="margin-bottom:
-20"><font size="2"><nobr>
<!--webbot bot="Validation" s-display-name="Division Page Choice"
b-disallow-first-item="TRUE" --><select name="section" size="1"
language="javascript" onChange="gotoPage(this.selectedIndex);">
<option selected value="Go to a Division page">Go to a Division
page</option>
<option>- - - - - - - - - - - - - - - - -</option>
<option>Building Division</option>
<option>Code Enforcement Division</option>
<option>Historic Preservation Commission</option>
<option>Planning & Zoning Commission</option>
<option>Planning Division</option>
<option>Waste Services Division</option>
<option>Zoning Division</option>
</select></font></nobr></p></form>
<script language="JavaScript">
<!--
function gotoPage(varItem)
{
switch(varItem)
{
case 0:
window.parent.self.status="Goes Nowhere";
break;
case 1:
window.parent.self.status="Goes Nowhere";
break;
case 2:
window.location="Building/BuildMain.html";
break;
case 3:
window.location="Code/CodeMain.html";
break;
case 4:
window.location="HPC/HPCMain.html";
break;
case 5:
window.location="PZC/PZCMain.html";
break;
case 6:
window.location="Planning/PlanMain.html";
break;
case 7:
window.location="WasteServ/WasteMain.html";
break;
case 8:
window.location="Zoning/ZoningMain.html";
break;
}
}
// -->
</script>

What do I have to change?

Thanks in advance.
 
K

Kevin Spencer

Anywhere before the </body>, but below the form element it references.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

pfldparkdistrict said:
Sorry, but I'm unsure exactly where to put that script.

Should it go before the </form> tag, after the </form> tag but before the
<script language> tag, before the </script> tag, or after the </script>
tag?

Thanks!

Kevin Spencer said:
Add this script at the bottom of the form:

<script type=text/javascript"><!--
document.forms[0].section.SelectedIndex = 0;
// --></script>

It will execute precisely ONE time whenever the page loads.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

pfldparkdistrict said:
I need help customizing javascript for a drop-down box (text needing
customization appears below). Here's what I want to do: when someone
selects
an option in my drop-down box, they are directed to the correct page.
When
they click "back" and go to the previous page, I want the drop-down box
selection to reset to the default option ("Go to a Division Page").
Currently, when someone clicks "back", they see the option they
selected
in
the drop-down box.

Here's the html for my drop-down box:

<form onsubmit="return FrontPage_Form1_Validator(this)"
language="JavaScript" name="FrontPage_Form1"><p style="margin-bottom:
-20"><font size="2"><nobr>
<!--webbot bot="Validation" s-display-name="Division Page Choice"
b-disallow-first-item="TRUE" --><select name="section" size="1"
language="javascript" onChange="gotoPage(this.selectedIndex);">
<option selected value="Go to a Division page">Go to a Division
page</option>
<option>- - - - - - - - - - - - - - - - -</option>
<option>Building Division</option>
<option>Code Enforcement Division</option>
<option>Historic Preservation Commission</option>
<option>Planning & Zoning Commission</option>
<option>Planning Division</option>
<option>Waste Services Division</option>
<option>Zoning Division</option>
</select></font></nobr></p></form>
<script language="JavaScript">
<!--
function gotoPage(varItem)
{
switch(varItem)
{
case 0:
window.parent.self.status="Goes Nowhere";
break;
case 1:
window.parent.self.status="Goes Nowhere";
break;
case 2:
window.location="Building/BuildMain.html";
break;
case 3:
window.location="Code/CodeMain.html";
break;
case 4:
window.location="HPC/HPCMain.html";
break;
case 5:
window.location="PZC/PZCMain.html";
break;
case 6:
window.location="Planning/PlanMain.html";
break;
case 7:
window.location="WasteServ/WasteMain.html";
break;
case 8:
window.location="Zoning/ZoningMain.html";
break;
}
}
// -->
</script>

What do I have to change?

Thanks in advance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top