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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

if..else statment giving syntax error

Status
Not open for further replies.

spastica

Programmer
Sep 27, 2002
72
GB
i have a quicklaunch dropdown menu containing links to different pdf documents.

when a user selects one of the documents in the dropdown, the documents opens up instantly in a new window.

this works fine, but the problem is, one of the options is not to launch a document. instead, it is to show a message on the current page saying we do not have documents for that area.

I can't figure out a way to conditionally open in a new window. I only need to open in a new window if there is a document being launched. if there is not, I need it to stay on the same page and show the message.

here's what I have but I get a syntax error:

<script language="JavaScript">
<!--
function jumpTo(form) {

var myindex=form.quicklaunch.selectedIndex;

if(myindex)==6

{

window.open(form.quicklaunch.options[myindex].value);
}

else

{
window.open(form.quicklaunch.options[myindex].value, target="_blank");

}


} // -->
</script>
 
nevermind, I made a stupid mistake by not putting brackets around the if condition! doh!

this worked fine:

<script language="JavaScript">
<!--
function jumpTo(form) {

var myindex=form.quicklaunch.selectedIndex;

if (myindex==6)

{

window.location=form.quicklaunch.options[myindex].value;

}

else

{
window.open(form.quicklaunch.options[myindex].value, target="_blank");

}


} // -->
</script>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top