javascript - Is it possible to passing data in same PHP file? -



javascript - Is it possible to passing data in same PHP file? -

i have button (someone created , need edit) saved $elisting in employee.php. button go javascript function named edit(). $elisting code below:

$elisting =""; $queryf = "select employee.id myid,jobtitle,info,locid,deptid,gender,dob,emid,employee$cid.name,username,dept,datejoin,location.name loc employee left bring together location on location$cid.id = employee.locid inner bring together section on department.id = employee.deptid order username "; $resultf = pg_query($queryf); $numrows = pg_numrows($resultf); while ($rowf = pg_fetch_array($resultf)) { $ct=$ct+1; $myid = $rowf[myid]; $uname = $rowf[username]; $loc1 = $rowf[loc]; $dept = $rowf[dept]; $date = $rowf[datejoin]; $name = $rowf[name]; $emid = $rowf[emid]; $dob = $rowf[dob]; $gender = $rowf[gender]; $job = $rowf[jobtitle]; $info = $rowf[info]; $datejoin = $rowf[datejoin]; $locid = $rowf[locid]; $deptid = $rowf[deptid]; $newbal = $rowf[newbal]; $templatelist = ""; $tempcn = 0; $querytemp = "select tid,ltype leaveatemplate$cid username='$uname' order tid desc"; $resulttemp = pg_query($querytemp); while ($rowtemp = pg_fetch_array($resulttemp)) { $tempcn = $tempcn +1; $tid = $rowtemp[tid]; $ltype = $rowtemp[ltype]; if($tempcn=="1") $templatelist = "$ltype|$tid"; else $templatelist = $templatelist.","."$ltype|$tid"; } $elisting=$elisting."<tr><td align=\"center\">$uname</td><td align=\"center\">$loc1</td><td align=\"center\">$dept</td> <td align=\"center\">$date</td> <td align=\"center\"><a><button class=\"btn btn-mini\"data-toggle=\"modal\"href=\"#long\" onclick=\"javascript:edit('$name','$uname','$emid','$dob','$gender','$job','$info','$datejoin','$locid','$deptid','$myid','$templatelist');\"><i class=\"icon-pencil\"></i></a>

here javascript edit() code:

function edit(a,b,c,d,e,f,g,h,i,j,k,l){ document.getelementbyid("frm").id.value=k; document.getelementbyid("frm").name.value=a; document.getelementbyid("frm").username.value=b; document.getelementbyid("frm").emid.value=c; document.getelementbyid("frm").dob.value=d; setcheckedvalue(document.forms['frm'].elements['gender'],e); document.getelementbyid("frm").job.value=f; document.getelementbyid("frm").info.value=g; document.getelementbyid("frm").datejoin.value=h; document.getelementbyid('locid').value=i; document.getelementbyid('deptid').value=m; var params = b; window.location.href="http://192.168.1.5/eleave/employee.php?lapplicant=" + params; var mytemp = l; var mysplitresult = mytemp.split(","); for(i = 0; < mysplitresult.length; i++){ cval = mysplitresult[i]; myval = cval.split("|"); val1 = myval[0]; val2 = myval[1]; document.getelementbyid('temp'+val1).value= val2; }

since failed seek many ways b in edit(), need find way $uname in $elisting , send $llisting in same php file (employee.php) code below:

$llisting =""; $ct=0; //leave code $ccompassionate = "3"; $cemergency = "4"; $cmaternity = "5"; $cmedical = "6"; $cannual = "2"; //leave value $compassionate = 2; $emergency = 5; $maternity = 60; $medical = 20; $lapplicant = $_post['lapplicant']; $querye = "select leavetype.id, leavetype.ltype, leaves.leave leavetype,leaves username='".$_session["username"]."'"; $resulte = pg_query($querye); while ($rowe = pg_fetch_array($resulte)) { $ct=$ct+1; $lid = $rowe[id]; $ltype = $rowe[ltype]; $leave = $rowe[leave]; if ($lid == $ccompassionate) { $compassionate_query = pg_query("select ltotal leave lapplicant='".$lapplicant."' , ltype='".$ccompassionate."'"); if (count($compassionate_query) > 0) { foreach ($compassionate_query $data) { $total_compassionate = $total_compassionate + $data['total']; $value = $compassionate - $total_compassionate; } } else { $value = $compassionate; } $llisting=$llisting."<tr><td align=\"center\">$ct</td><td>$ltype</td><td><input type='text' value='$lapplicant'></td><td align=\"center\">"; $llisting=$llisting."<select name=\"temp$lid\" id=\"temp$lid\" class=\"span12\"><option value=\"0\"> - </option> $tlisting</select>"; $llisting=$llisting."</td></tr>\n";

anyone have thought $uname in $elisting , send $llisting?

and also, how can '$name','$uname','$emid','$dob','$gender','$job','$info','$datejoin','$locid','$deptid','$myid','$templatelist' in $elisting alter a,b,c,d,e,f,g,h,i,j,k,l in edit(), i'm new in javascript don't understand how can change?

thank help..

this code href="#long" called:

<div id="long" class="modal hide fade" tabindex="-1" data-replace="true" data-width="760"> <div class="modal-header"><h3>employee profile</h3></div> <div class="modal-body"> <form class="form-horizontal" method="post" name="frm" id="frm">

code phone call html page:

if($msg!="") $alert= "<div class=\"alert\"><i class=\"icon-info-sign\"></i> $msg</div><p>&nbsp;</p>"; $source2 = file_get_contents('http://'.$_session["url"].'/cgi-bin/vo/'.$_session["sessid"].'.interface.designer.vo?file=eleave/employee.htm'); $html2 = str_replace("[templateurl]",$templateurl,$source2); $html2 = str_replace("[alert]",$alert ,$html2); $html2 = str_replace("[elisting]",$elisting ,$html2); $html2 = str_replace("[ulisting]",$ulisting ,$html2); $html2 = str_replace("[locationlisting]",$locationlisting ,$html2); $html2 = str_replace("[deptlisting]",$deptlisting ,$html2); $html2 = str_replace("[llisting]",$llisting ,$html2); $html2 = str_replace("[wfid]","sid=$sid" ,$html2); echo $html2;

please seek basic first, have no problem one.

in js:

<script> function testtriggered(name){ alert("the function triggered!"); alert("my name is: " + name); } </script>

on html part

<input type="button" name="mybutton" onclick="javascript:testtriggered('john');" value="please click"/>

please seek first , see how thing works.

javascript php

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -