|
-
Nov 2nd, 2001, 03:11 AM
#1
Thread Starter
Junior Member
JS problem: script writes "true" to screen
Here is my code:
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:
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
-
Nov 2nd, 2001, 06:51 AM
#2
Conquistador
Re: JS problem: script writes "true" to screen
Not tested:
Code:
<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
-
Nov 2nd, 2001, 09:36 AM
#3
Frenzied Member
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.
Travis, Kung Foo Journeyman
As always, RTFM.
WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
YBMS, but Mozilla doesn't.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|