Jump to content

loading select box from php


natalieG

Recommended Posts

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
Link to comment
Share on other sites

Hi natalieG,

I think I found your problem javascript is case sensitive use a small "a" for Alert, you need to chage ur code :
[quote]
echo "<select name= \"MySelect\" onChange=\"Alert('Hi')\">";
[/quote]
To this:
[quote]
echo "<select name= \"MySelect\" onChange=\"alert('Hi')\">";
[/quote]

Here is a full example seperate of databse connectivity:
[quote]
<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>
[/quote]

If you still have troubles give me a shout.  ;)
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.