tcsnguy08
05-26-2009, 11:13 PM
Hello everyone.
Thanks in advance for any help someone can give me. First I will explain a little about what I want to do. I have a javascript will a) look for a certain value in a drop down box and b) depending on what value is selected open up a div that includes link that when moused over will pop up with an alert box contain the passed parameter. A couple problems with this, one is I am not as sharp on Javascript as I am on PHP, and two, when I manually place a value into the function parameter, if it's a number it works fine, but if its a string or word, it comes up with an undefined error. Can someone please help me find why the undefined error is coming up only on strings or words? Thanks again. I am using PHP so sorry for the \escapes.
echo"<head>
<script type=\"text/javascript\">
/* This function displays the div and writes the appropriate HTML. */
function Makediv(){
var boxvalue = document.getElementById('choose').value;
if (boxvalue == '1'){
document.getElementById('choices').style.display = 'inline';
document.getElementById('choices').innerHTML = '<a href=\"index.php\" onmouseover=\"Test($band[1])\">Hello</a>';
} else if (boxvalue == '2'){
document.getElementById('choices').style.display = 'inline';
document.getElementById('choices').innerHTML = '<a href=\"index.php\" onmouseover=\"Test($band[2])\">goodbye</a>';
} else {
document.getElementById('choices').style.display = 'none';
}
}
/* This function pops up with an alert when the link is mousedover. The alert should display the parameter passed in Test() Doesn't work comes back with an undefined error */
function Test(bandname){
var band = bandname;
alert(band);
}
/* Here is the HTML for the page */
</script>
</head>
<body><form action=\"#\"><select name=\"choose\" id=\"choose\" onchange=\"Makediv()\"><option value=\"\" selected>SELECT</option><option value=\"1\">".$band[1]."</option><option value=\"2\">".$band[2]."</option></select></form><br><br><div style=\"border : solid 1px #888888; background : #000000; color : #ffffff; padding : 4px; width : 500px; height : 200px; overflow : auto; display:none; \" name=\"choices\" id=\"choices\"></div></body>";
Thanks in advance for any help someone can give me. First I will explain a little about what I want to do. I have a javascript will a) look for a certain value in a drop down box and b) depending on what value is selected open up a div that includes link that when moused over will pop up with an alert box contain the passed parameter. A couple problems with this, one is I am not as sharp on Javascript as I am on PHP, and two, when I manually place a value into the function parameter, if it's a number it works fine, but if its a string or word, it comes up with an undefined error. Can someone please help me find why the undefined error is coming up only on strings or words? Thanks again. I am using PHP so sorry for the \escapes.
echo"<head>
<script type=\"text/javascript\">
/* This function displays the div and writes the appropriate HTML. */
function Makediv(){
var boxvalue = document.getElementById('choose').value;
if (boxvalue == '1'){
document.getElementById('choices').style.display = 'inline';
document.getElementById('choices').innerHTML = '<a href=\"index.php\" onmouseover=\"Test($band[1])\">Hello</a>';
} else if (boxvalue == '2'){
document.getElementById('choices').style.display = 'inline';
document.getElementById('choices').innerHTML = '<a href=\"index.php\" onmouseover=\"Test($band[2])\">goodbye</a>';
} else {
document.getElementById('choices').style.display = 'none';
}
}
/* This function pops up with an alert when the link is mousedover. The alert should display the parameter passed in Test() Doesn't work comes back with an undefined error */
function Test(bandname){
var band = bandname;
alert(band);
}
/* Here is the HTML for the page */
</script>
</head>
<body><form action=\"#\"><select name=\"choose\" id=\"choose\" onchange=\"Makediv()\"><option value=\"\" selected>SELECT</option><option value=\"1\">".$band[1]."</option><option value=\"2\">".$band[2]."</option></select></form><br><br><div style=\"border : solid 1px #888888; background : #000000; color : #ffffff; padding : 4px; width : 500px; height : 200px; overflow : auto; display:none; \" name=\"choices\" id=\"choices\"></div></body>";