yusufhermanto Posted May 20, 2007 Share Posted May 20, 2007 Hello all, i'm new on php programming, and i have problem about this. i have code like this : <script language="JavaScript"> function Displaydata() { var kdcust = document.frmpo.cbocust.value; alert(kdcust); <? $kd= document.frmpo.cbocust.value; $s="select * From customer where kd_cust='".$kd."'"; $rs = mysql_query($s); $row=mysql_fetch_array($rs,MYSQL_BOTH); ?> document.getElementById("telp").value='<? echo $row["telp"]; ?>'; } </script> i want to get data from "document.frmpo.cbocust.value" object. and i try enter on $kd variable : $kd= document.frmpo.cbocust.value; but i can not get data from this dasta. what is wrong with my code ? please help me thanks Quote Link to comment https://forums.phpfreaks.com/topic/52198-problem-on-php-code-within-javascript-code/ Share on other sites More sharing options...
Lumio Posted May 20, 2007 Share Posted May 20, 2007 Javascript is working on you Browser. So that has nothing to do with PHP. PHP is a language for the Server. When you get to a PHP-File you don't see any codes. What you're trying to do is getting data to use it to get another information of mysql. AJAX will help you Quote Link to comment https://forums.phpfreaks.com/topic/52198-problem-on-php-code-within-javascript-code/#findComment-257428 Share on other sites More sharing options...
yusufhermanto Posted May 20, 2007 Author Share Posted May 20, 2007 Javascript is working on you Browser. So that has nothing to do with PHP. PHP is a language for the Server. When you get to a PHP-File you don't see any codes. What you're trying to do is getting data to use it to get another information of mysql. AJAX will help you yes i want to automatically display data from mysql when i get code from database. this step of my scrpt: 1. display data from to Drop Down Box and this mycode : <td width="45%" height="19"><select size="1" name="cbocust" onChange='Displaydata()'> <? $rs = mysql_query("select nm_cust,kd_cust from customer order by kd_cust"); $b=0; while($row=mysql_fetch_array($rs,MYSQL_BOTH)){ $b++; echo "<option value=".$row["kd_cust"].">".$row["nm_cust"]."</option>"; } ?> </select></td> 2. and then i want to display automatically all data from customer data when choose value of cbocust ( the code on the above posted) do you have other solution for my problem ? Quote Link to comment https://forums.phpfreaks.com/topic/52198-problem-on-php-code-within-javascript-code/#findComment-257430 Share on other sites More sharing options...
Lumio Posted May 20, 2007 Share Posted May 20, 2007 I told you: AJAX Here is a little tutorial: AJAX:Getting Started Quote Link to comment https://forums.phpfreaks.com/topic/52198-problem-on-php-code-within-javascript-code/#findComment-257451 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.