Jump to content


Photo

loading select box from php


  • Please log in to reply
1 reply to this topic

#1 natalieG

natalieG
  • Members
  • PipPipPip
  • Advanced Member
  • 63 posts

Posted 20 July 2006 - 01:29 PM

we are loading a selct box in ato an html page via AJAX weith this script. The
select box shows up fine, but the alert box does not trigger  when we select items.

echo "<select name= \"MySelect\" onChange=\"Alert('Hi')\">";
while ($LBOXROW=mysql_fetch_array($LBOXFIND,MYSQL_ASSOC)){
$MYNAME=$LBOXROW[SPNAME];$PINDEX=$LBOXROW[PINDEX];
echo "<option value=\"$PINDEX\">$MYNAME</option>\n";
}//while
echo "</select>";

Thanks,

Jennifer


#2 manichean

manichean
  • Members
  • PipPip
  • Member
  • 29 posts

Posted 20 July 2006 - 01:39 PM

Hi natalieG,

I think I found your problem javascript is case sensitive use a small "a" for Alert, you need to chage ur code :

echo "<select name= \"MySelect\" onChange=\"Alert('Hi')\">";

To this:

echo "<select name= \"MySelect\" onChange=\"alert('Hi')\">";


Here is a full example seperate of databse connectivity:

<html>
<body>
<?php
echo "<select name= \"MySelect\" onChange=\"alert('Hi')\">\n";
$i =0;
while ($i < 5){
$i ++;
$MYNAME= "Option".$i;
echo "<option value=\"$i\">$MYNAME</option>\n";
}
echo "</select>\n";
?>
</body>
</html>


If you still have troubles give me a shout.  ;)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users