Jump to content

passing variable value of javascript to php in one file php

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 post
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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...