Passing Javascript variable to php
Posted: Thu Aug 16, 2007 6:16 am
feyd | Please use
How can I pass the above java script variable c_catg to my %t1 variable to form where clause value in $sql. This variable c_catg has integer value, hence written this way to construct $sql.
Please guide.
Thanks & Regards,
Naimesh Trivedi
nbtrivedi@hotmail.com
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Dear Sir,
Hello ! I want to get the javascript variable in php code in following functionCode: Select all
script language="JavaScript">
function chg_subcatg(cfield,fieldnm)
{
// For Retrieval of current catg
var f1=document.forms[0];
var sbox1=f1.elements[cfield];
var choice=sbox1.selectedIndex;
var [b] c_catg [/b]= sbox1.options[choice].value;
document.forms[0].thefield.value = c_catg;
// For updation of sub category
var f=document.forms[0];
var selectBox=f.elements[fieldnm];
<?php
require_once "../functions_main.inc";
$cxn = Connect_to_db("../vars.inc");
// $sql = "select * from subcatg_mast where catg_id = 1";
$sql = "select * from subcatg_mast where catg_id = " . $t1;
$result = mysql_query($sql);
while ($row = mysql_fetch_array($result))
{
?>
var extraOption=new Option('<?php echo $row['subcatg_desc'];?>','<?php echo $row['catg_id'];?>',0,0);
selectBox.options[selectBox.options.length]=extraOption;
<?php
}
?>
}Please guide.
Thanks & Regards,
Naimesh Trivedi
nbtrivedi@hotmail.com
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]