I am newbie in php and still learn javascript function.
I have a problem with, include javascript variable into php query.
I want to create transaction code according count of part code which have different type. then i must get value with count.
<script language="javascript" type="text/javascript">
function getCode(){
var v =document.forms["form1"]["part_code"].value;
<?php
$query = mysql_query("SELECT COUNT(*)+1 as count FROM TB_TRANSACTION where part_code = "<script>v;</script>"");
$i=-1;
while ($code_part = mysql_fetch_array($query))
{
$i++;
?>
var getPartCode = <? echo $code_part['count'];?>;
var x = document.forms["form1"]["part_code"].value;
var y = document.forms["form1"]["location_code"].value;
var z = document.forms["form1"]["date"].value;
var a = (getPartCode + '/'+x +'/'+ y +'/'+ z);
document.forms["form1"]["invent_code"].value = a;
<?
}
?>
</script>
The result like that 1/CPU/JKT/2013
I call that function with button onClick="getCode()"
no submit.
Anyone can help me.