Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascipt Syntax

Status
Not open for further replies.

awieland

Programmer
Apr 18, 2005
36
0
0
US
In my Javascript I want to add a third section, which calls a "option C" in my select statement. I am not able to get the correct syntax in the Javascript. Using the return in the javascript in the current location will show the first and second section, but when I add the third section nothing works. Does anyone have any ideas on the syntax?. In addtion, I want to stay with this format in the the Javascript.

<!-- Javascript: -->

<script language="JavaScript1.2">
function whichColour(obj){

if(obj.group_name.selectedIndex == 1)
<!-- Section 1 -->
{
obj.directory.length=2
obj.directory.options[0].value="msds_pds/QEP Product Data Sheets/"
obj.directory.options[0].text="msds_pds/QEP Product Data Sheets/"
obj.directory.selectedIndex = 0
return
}
<!-- Section 1 -->
obj.directory.length=2
obj.directory.options[0].value="msds_pds/CANADA/Product Data Sheet/CANPDS/"
obj.directory.options[0].text="msds_pds/CANADA/Product Data Sheet/CANPDS/"
obj.directory.selectedIndex = 0

<!-- Section 3, this is the section I want to add but the syntax is not correct-->

obj.directory.length=2
obj.directory.options[0].value="msds_pds/test/"
obj.directory.options[0].text="msds_pds/test/"
obj.directory.selectedIndex = 0
}

</script>

<!-- Select statement: -->

<td>
<select name="selectBorder" onchange="whichColour(this.form)">
<option>-- select --</option>
<option value="QEP Product Datasheets">QEP Product Datasheets</option>
<option value="Roberts Adhesive Product Datasheets (Canada English)">Roberts Adhesive Product Datasheets (Canada English)</option>
<option value="Roberts Adhesive Product Datasheets (USA)">Roberts Adhesive Product Datasheets (USA)</option>
</select>
</td>

<td>
<select name="selectColour" onchange="whichColour(this.form)">
<option>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>
<option></option>
<option></option>
<option></option>
<option></option>
<option></option>
<option></option>
</select>
</td>
 
I was not able to use your previous reference. I need to stay with the javascript format in my new thread. The switch syntax you reffered me to did not work in my case.

<!-- Javascript -->

function whichColour(obj){

if(obj.group_name.selectedIndex == 1)
<!-- Section 1 -->
{
obj.directory.length=2
obj.directory.options[0].value="msds_pds/QEP Product Data Sheets/"
obj.directory.options[0].text="msds_pds/QEP Product Data Sheets/"
obj.directory.selectedIndex = 0
return
}
<!-- Section 1 -->
obj.directory.length=2
obj.directory.options[0].value="msds_pds/CANADA/Product Data Sheet/CANPDS/"
obj.directory.options[0].text="msds_pds/CANADA/Product Data Sheet/CANPDS/"
obj.directory.selectedIndex = 0

<!-- Section 3, this is the section I want to add but the syntax is not correct-->

obj.directory.length=2
obj.directory.options[0].value="msds_pds/test/"
obj.directory.options[0].text="msds_pds/test/"
obj.directory.selectedIndex = 0
}

</script>


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top