Hi, JavaScript codes works in php files. Yours code is also fine. But check your calling function and defined functions. Calling function is jsopsi and defined function is opsi. Please check. Other than this everything is ok Warm Regards, Sanjeev http://www.sanchanworld.com/ http://webdirectory.sanchanworld.com - Submit your website URL http://webhosting.sanchanworld.com - Choose your best web hosting plan -----Original Message----- From: Patrik Hasibuan [mailto:patrikh@xxxxxxxxxxxxxxxxxxxxx] Sent: Saturday, August 25, 2007 9:17 PM To: php-general@xxxxxxxxxxxxx Subject: Does JavaScript not work in php web file? Dear my friends... I am confused to implement JavaScript code in php web file. I want my JavaScript change the "selected" item of <select> tag based on the "selected" item of previous <selected> in same php page. Please help me.... tell my where is my mistake. === Here is my code pelangganbaru.php === <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <HTML> <HEAD> <META name="generator" content="HTML Tidy for Linux/x86 (vers 31 October 2006), see www.w3.org"> <TITLE>guru.com - Menu for new customer</TITLE> </HEAD> <Script Language="JavaScript"> function opsi(){ if (document.formulir.opsinegara.value!="Virgina Islands (USA)";){ document.formulir.opsistate.options[0].selected=true; } } </Script> <BODY> <?php if (isset($pid)){ $idproduk=$_GET['pid']; echo "Produk ID: $idproduk<br>"; } ?> <table border=0 align="center" cellpadding=0 cellspacing=0 width=800> <tr><td></td><td><table border=0 align="center" cellpadding=0 cellspacing=0 width=400> <form method="post" action="cgi/cgipelangganbaru.php?pid=$idproduk" name="formulir"> <tr> <td align="right" bgcolor="#F5D78B"> 3. Country: </td> <td align="center"> </td> <td align="left"> <select name="negara" onchange="jsopsi()" name="opsinegara"> <?php include_once "koneksi.php"; $sqlnya="select country from countries"; $kelas=new koneksi(); $klas=$kelas->getkoneksi("survey",$sqlnya); if ( mysql_num_rows($klas) > 0 ) { while( list($negara) = mysql_fetch_row($klas) ) { echo "<option id=\"opsi"."$negara\" value=\"$negara\">$negara</option>"; } } else { echo 'No results found'; } ?> </select> </td> </tr> <tr> <td align="right" bgcolor="#F5D78B"> 4. State: </td> <td align="center"> </td> <td align="left"> <select name="opsistate"> <?php include_once "koneksi.php"; $sqlnya="select state,statename from states"; $kelas=new koneksi(); $klas=$kelas->getkoneksi("survey",$sqlnya); if ( mysql_num_rows($klas) > 0 ) { echo "<option name=\"opsi".$state."\" value=\"\"></option>"; if ($negara=="Virgin Islands (US)"){ echo "<option name=\"nonusa\" value=\"00\" selected>Non USA</option>"; }else{ echo "<option name=\"nonusa\" value=\"00\">Non USA</option>"; } while( list($state,$statename) = mysql_fetch_row($klas) ) { echo "<option name=\"state\" value=\"$state\">$statename ($state)</option>"; } } else { echo 'No results found'; } ?> </select> </td> </tr> <tr> <td align="right"> <input type="submit"> </td> <td align="center"> </td> <td align="left"> <input type="reset"> </td> </tr> </form> </table> </td><td></td></tr></table> </BODY> </HTML> -- Patrik Hasibuan <patrikh@xxxxxxxxxxxxxxxxxxxxx> Junior Programmer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php