PDA

Click to See Complete Forum and Search --> : JS problem: script writes "true" to screen


tahoer111
Nov 2nd, 2001, 02:11 AM
Here is my code:


function menu(dropdown) {
var myindex = dropdown.selectedIndex
var SelValue = dropdown.options[myindex].value
if (SelValue == "no") {
alert("Please select an item to view information")

} else {
var url = "pizza.php?request=menu&mvalue=" + SelValue
window.open(url,'mywindow','width=225,height=250 toolbar=no statusbar=no')
return true;
}

}


and the link which I use to call this code:


<a href='javascript:menu(document.menuForm.pizza_options);'>Link</a>


When I do this, everything goes as expected, except that "true" is written to the base window. Why does this happen and how can I fix it? Thanks

da_silvy
Nov 2nd, 2001, 05:51 AM
Not tested:

<a href="file.htm#" onclick='javascript:menu(document.menuForm.pizza_options);'>Link</a>

<a href="#" onclick='javascript:menu(document.menuForm.pizza_options);'>Link</a>

<a href="" onclick='javascript:menu(document.menuForm.pizza_options);'>Link</a>


One of them should have the desired effect

CiberTHuG
Nov 2nd, 2001, 08:36 AM
Why put this in an anchor tag? You can put in in the onclick event in a span tag, give it a class that you define in the CSS to look like an anchor link.

Aside from that, leave out the "return true" line. The function will return on its own, you don't need to explicitly tell it to return and to return a value.