Jump to content

passing variable value of javascript to php in one file php


flix_is_here22

Recommended Posts

hey anyone, i have a problem about passing variable. gridpEmp.PHP

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><HTML><HEAD><TITLE></TITLE><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta http-equiv="Content-Style-Type" content="text/css"><meta http-equiv="Content-Script-Type" content="text/javascript"><script type="text/javascript">var preEl ;var orgBColor;var orgTColor;function HighLightTR(el, backColor,textColor){  var rowindex = el.sectionRowIndex;   if(typeof(preEl)!='undefined') {	 preEl.bgColor=orgBColor;	 try{ChangeTextColor(preEl,orgTColor);}catch(e){;}  }  orgBColor = el.bgColor;  orgTColor = el.style.color;  el.bgColor=backColor;  try{ChangeTextColor(el,textColor);}catch(e){;}  preEl = el;}function ChangeTextColor(a_obj,a_color){  ;   for (i=0;i<a_obj.cells.length;i++)	a_obj.cells(i).style.color=a_color;}<style>table.selectable-table td {  font-size:10pt; font-family: Arial;   }table.selectable-table td {  cursor:pointer;  margin:0px; border:0px; padding:2px 5px 2px 5px;   }table.selectable-table  {  border-spacing:0px;  background:#eef;}</style></script></HEAD><BODY><table id="gridemp" border="1" cellspacing="0" cellpadding="4"  align="center"><th>Employee Initial</th><th>Employee ID</th><th>Employee Name</th><tbody><?phpinclude('check/conDBodbc.php');$empid = $_POST['searchemployee']; function dbquery($sql) {include('check/conDBodbc.php');  $arr	= array();  $rs	 = odbc_exec($con,$sql);  $x	  = 1;  while (odbc_fetch_row($rs)) {	for ($y = 1; $y <= odbc_num_fields($rs); $y++)	  $arr[$x][$y] = odbc_result($rs,$y);	$x++;  }  if ($x > 1)	return $arr;}$arr = dbquery("select * from getemployee where employeeid like '%$empid%' or employeename like '%$empid%' or employeeinitial like '%$empid%'");echo $arr[1][3]; $rs1 = odbc_exec($con,"select * from getemployee where employeeid like '%$empid%' or employeename like '%$empid%' or employeeinitial like '%$empid%'");while(odbc_fetch_array($rs1)){?><tr  onClick="HighLightTR(this,'#c9cc99','cc3333')"><!--<tr onClick="getvalue(this)">--><td align=left><?php echo odbc_result($rs1,employeeinitial);?></td><td align=left><?php echo odbc_result($rs1,employeeid);?></td><td align=left><?php echo odbc_result($rs1,employeename);?></td></tr><?php  }?></tbody></table></BODY></HTML>

i want to passing variable var rowindex = el.sectionRowIndex;how to do that passing variable in one file php??because i want to get value of row index from user selected row after that i can echo value of selected row from user by function dbquery($sql).

Edited by flix_is_here22
Link to comment
Share on other sites

You will need a separate PHP file and have to learn AJAX. Javascript cannot communicate directly with PHP. PHP is executed on the server and once the page has loaded it will not run anymore. You should look at the W3Schools AJAX tutorial, but be sure you understand Javascript well first.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...