Jump to content


Photo

Dynamic List Box


  • Please log in to reply
1 reply to this topic

#1 natalieG

natalieG
  • Members
  • PipPipPip
  • Advanced Member
  • 63 posts

Posted 27 July 2006 - 03:13 PM

The select box gets created fine, buit the alert does not function. Really weird, the code
is much like one we use all the time.

Thanks,

Jennifer

<?php
if (isset($_REQUEST['INDEXA']) and (strlen($_REQUEST['INDEXA'])>0))
{$MYINDEX=$_REQUEST['INDEXA'];} else {echo 'NO INDEXA'; exit;}

define('DB_HOST','localhost');
define('DB_USER','msdsimg');
define('DB_PASSWORD','misner01');
define('DB_NAME','msdsimg');
$conn=mysql_connect(DB_HOST,DB_USER,DB_PASSWORD) or die ('Did Not Connect');
mysql_select_db(DB_NAME) or die ('Cannot Set Database');
$CONTACTQUERY="SELECT
  CONTACTNAME,CLIENTINDEX,INDEXA
              FROM PIMCONTACTS
              WHERE CLIENTINDEX=$MYINDEX
              ORDER BY CONTACTNAME";

$CONTACTFIND=mysql_query($CONTACTQUERY)  or  die ('CONTACT QUERY ' . mysql_error());
$CONTACTCOUNT=mysql_num_rows($CONTACTFIND);
if($CONTACTCOUNT >=5){$SIZE=5;} else  {$SIZE=1;}
$RESULTSTR="<SELECT ID=\"CONTID\" NAME=\"CONTSEL\" SIZE=\"$SIZE\">";
$RESULTSTR .= "<OPTION VALUE=\"0\">Select CONTACT</OPTION>";
while ($CONTACTROW=mysql_fetch_array($CONTACTFIND,MYSQL_ASSOC)){
$CONTACTINDEX=$CONTACTROW[INDEXA];$CONTACTNAME=$CONTACTROW[CONTACTNAME];
$RESULTSTR .=
    "<OPTION VALUE=\"$CONTACTINDEX\" onChange=\"alert('Hi')\">$CONTACTNAME</OPTION>";
}//while
$RESULTSTR .="</SELECT>";
echo $RESULTSTR;
mysql_close();
?>

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 27 July 2006 - 03:15 PM

onChange=\"alert('Hi')\" is in the wrong place, it shoud be in the select tag:
<SELECT ID=\"CONTID\" NAME=\"CONTSEL\" SIZE=\"$SIZE\" onChange=\"alert('Hi')\">





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users