PHP - Php And Javascript Problem Help?
Similar TutorialsI didn;t know if I should put this in javascript or in PHP as it covers both in a way, but as there is nobody in the Javascript forum I put it here. Here is my problem: I have a script that get's info from a mysql database and makes it into a navigation bar (The bar is in Javascript.) And the 'url' bit seems to be the problem. - If I type the url in Manually, "index.php?catt=mainpage-home" Then it works, no problem. But if I type: "' . $rowa['url'] . '" then the menu doesn't drop. The rowa[''] method works fine because it works for the 'name' bit. Just the url seems to not work. I will post the code below. <?php include "../../includes/mysql_connect.php"; include "../../includes/info_files.php"; ?> <link rel="stylesheet" href="http://www.controlhabbo.net/layout/global.css" type="text/css" /> <link rel="stylesheet" type="text/css" href="http://www.controlhabbo.net/layout/menu/anylinkmenu.css" /> <script type="text/javascript"> <?php $result = mysql_query("SELECT * FROM nav_title"); while($row = mysql_fetch_array($result)) { echo 'var ' . $row['id'] . '={divclass:\'anylinkmenu\', inlinestyle:\'width:150px; border: solid black 1px; background:#ebebeb\', linktarget:\'\'} ' . $row['id'] . '.items=[ '; $resulta = mysql_query("SELECT * FROM nav_sub WHERE titlereg='$row[reg]'"); $num = mysql_numrows($resulta); while($rowa = mysql_fetch_array($resulta)) { $url = $rowa['url']; echo ' ["' . $rowa['name'] . '", "index.php?catt=main&page=home"]'; ////// --------- "' . $rowa['url'] . '" ----------------- Here is the error!!! ------------- if($num > 1) echo ','; echo ' '; $num = $num - 1; if($num == 0) { $num = mysql_numrows($resulta); } } echo '] '; } ?> </script> <script type="text/javascript" src="http://www.controlhabbo.net/layout/menu/anylinkmenu.js"></script> <script type="text/javascript"> //anylinkmenu.init("menu_anchors_class") //Pass in the CSS class of anchor links (that contain a sub menu) anylinkmenu.init("menuanchorclass") </script> <div id="navbar"> <div id="navbardropdown"> <?php $resultb = mysql_query("SELECT * FROM nav_title"); while($rowb = mysql_fetch_array($resultb)) { echo '<a href="" class="menuanchorclass" rel="' . $rowb['id'] . '">'; echo '<img src="http://www.controlhabbo.net/layout/images/buttons/' . $rowb['id'] . '.png" style="border-width:0" />'; echo '</a>'; } ?> </div> </div> It's nothing to do with the include files, as it works if I type in the url manually, just not if I use the MY SQL database. Any help would be great! This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=334294.0 Hello everyone , I have form and I am using action create2.php and everything is working when I want to send to my database information through the form .. This are codes : Code: [Select] <form action="create2.php" method="post"> <p>email</p> <input type="text" name="inputPayer_email" value="" /> <br/> <p>Name</p> <input type="text" name="inputFirst_name" value="" /> <br/> <p>Last name</p> <input type="text" name="inputLast_name" value="" /> <br/> <p>Address 1</p> <input type="text" name="inputAddress_street" value="" /> <br/> <p>Address 2</p> <input type="text" name="inputAddress_city" value="" /> <br/> <p>State</p> <input type="text" name="inputAddress_state" value="" /> <br/> <p>Mobile number</p> <input type="text" name="inputcmd" value=""> <br/> <input type="submit" name="submit" value="submit" /> </form> and create2.php code is Code: [Select] <?php $db_host = "mysqlxxx.host.com"; // Place the username for the MySQL database here $db_username = "nia"; // Place the password for the MySQL database here $db_pass = "pass"; // Place the name for the MySQL database here $db_name = "db"; // Run the actual connection here mysql_connect("$db_host","$db_username","$db_pass") or die ("could not connect to mysql"); mysql_select_db("$db_name") or die ("no database"); ?> <?php $Payer_email = $_POST['inputPayer_email']; $First_name = $_POST['inputFirst_name']; $Last_name = $_POST['inputLast_name']; $Address_street = $_POST['inputAddress_street']; $Address_city = $_POST['inputAddress_city']; $Address_state = $_POST['inputAddress_state']; $cmd = $_POST['inputcmd']; mysql_query("INSERT INTO `transactions` ( `payer_email` , `first_name` , `last_name` , `address_street` , `address_city` , `address_state` , `cmd` , ) VALUES (NULL , '$Payer_email', '$First_name', '$Last_name', '$Address_street', '$Address_city', '$Address_state', '$cmd')") or die(mysql_error()); //!!!!!!!!!!!!!!!!!!!!!!!!! Email User the activation link !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! $to = "$Payer_email"; $from = "admin@mywebsite.com"; $subject = "Your order .."; //Begin HTML Email Message $message = "Hi $First_name, Thank you , bla bla .. "; //end of message $headers = "From: $from\r\n"; $headers .= "Content-type: text\r\n"; mail($to, $subject, $message, $headers); $msgToUser = "Thank you .. "; include_once 'hvala.php'; exit(); // Close else after duplication checks header('Location: hvala.php'); ?> And this is redirecting me to hvala.php and sending e-mail for those who ordered something .. But when I want to add javascript so I can validate my web form , sending information in database is not working . I named form with "m" and action is create2.php , javascript works but my order form is not sending to my database anything .. Only blank fields in database .. I will give code with javascript , so if anyone see where is mistake , please write on thread .. Thank you in advance Code: [Select] <script type="text/javascript" language="javascript"> <!-- function validateMyForm ( ) { var isValid = true; if ( document.m.inputPayer_email.value == "" ) { alert ( "Insert email" ); isValid = false; } else if ( document.m.inputPayer_email.value.length < 1 ) { alert ( "Insert email" ); isValid = false; } else if ( document.m.inputFirst_name.value == "" ) { alert ( "First name" ); isValid = false; } else if ( document.m.inputLast_name.value == "" ) { alert ( "Last name" ); isValid = false; } else if ( document.m.inputAddress_street.value == "" ) { alert ( "Address" ); isValid = false; } else if ( document.m.inputAddress_city.value == "" ) { alert ( "Address" ); isValid = false; } else if ( document.m.inputAddress_state.value == "" ) { alert ( "State" ); isValid = false; } else if ( document.m.inputcmd.value == "" ) { alert ( "Mobile number" ); isValid = false; } return isValid; } //--> </script> <form name="m" action="create2.php""> <p>email</p> <input type="text" name="inputPayer_email" value="" /> <br/> <p>Name</p> <input type="text" name="inputFirst_name" value="" /> <br/> <p>Last name</p> <input type="text" name="inputLast_name" value="" /> <br/> <p>Address 1</p> <input type="text" name="inputAddress_street" value="" /> <br/> <p>Address 2</p> <input type="text" name="inputAddress_city" value="" /> <br/> <p>State</p> <input type="text" name="inputAddress_state" value="" /> <br/> <p>Mobile number</p> <input type="text" name="inputcmd" value=""> <br/> <input name="button" type="submit" value="Submit Information" onclick="javascript:return validateMyForm();"/> </form> Hello, I have a php code within a javascript. The javascript gets invoked on button click. The php code withing javascript never gets executed. I don't face the same problem in other browsers. Any help is much appreciated! Regards, Cole Hello,
I want to download flight from Wizzair page.
I've checked all headers which are sended when browser "create" request (the same which Ryanair few months ago).
It looks like this in my browser: I believe this is a PHP problem rather than a javascript one, but stand to be corrected. The following code shows two echo statements, with the second one commented out. The uncommented statement inside the javascript will not work, because while it calls up the check.php file it does not send the associated parameters correctly. I have left the commented echo in because it works perfectly. What's wrong? I know that javascript works client side, but the relevant php code has already run so the javascript should work. Code: [Select] <?php // code associated with a database query precedes this if ("{$row['passState']}" == 0) { ?> <script language="javascript" type="text/javascript" > <-- var newwindow; function popup() { newwindow = window.open('check/check.php?quizTitle=".urlencode($quizTitle)."','_blank','scrollbars=yes,top=0,left=0,width='+screen.width+',height='+screen.height); if (window.focus) {newwindow.focus()} } //--> </script> <?php echo '<form><input type="button" onClick="popup()" value="Check your answers"></form> '; //echo "<A HREF=\"check/check.php?quizTitle=".urlencode($quizTitle)."\" onClick=\"return popup(this, 'thoughts', 'scrollbars=1'); window.moveTo(0,0); window.resizeTo(screen.width,screen.height-100);\">Check your answers</A>."; } ?> My justification for presenting a full screen popup for students is so that they can see answers they have given in an earlier quiz. I find that if their popup is just a window over their working page, they can use the popup to just fill in their answers on a second attempt. Full screen mode will limit this. Hi... I have a problemand I tried to resolved it but still I failed.. I need to add a code in a php file where I'm not the one who code, now I need to add code on that file, and the problem is the one who the owner of code is not here. I need to add code : Code: [Select] $sub_lotcode = substr($lotCode, 9, 4); $sql = "SELECT k.PCODE, k.kanban, p.Compounds, p.Max_Lot FROM kanban_checker k, param_settings p WHERE k.kanban = p.Max_Lot AND k.PCODE = '$sub_lotcode' AND p.Compounds = '$sub_lotcode'"; $result = mysql_query($sql, $con); $total = mysql_num_rows($result); if ($total <= 0) { notify that PCODE reach the maximum } else{ echo "continue"; } here is the code where I need to add this condition: Code: [Select] <?php error_reporting(0); $con = mysql_connect('localhost', 'root',''); if (!$con) { echo 'failed'; die(); } mysql_select_db("mes", $con); $lotCode = mysql_real_escape_string($_GET['normal']); $lotCodeDownGrade = mysql_real_escape_string($_GET['downgrade']); $terminalNo = mysql_real_escape_string($_GET['n']); $downMode = mysql_real_escape_string($_GET['down']); //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> if ($terminalNo == "1") { if ($lotCode != "") { $sql = "SELECT BARCODE FROM LEGALCODES WHERE BARCODE='$lotCode'"; $result = mysql_query($sql, $con); $total = mysql_num_rows($result); if ($total <= 0) { echo "X"; // X - for non existent in the mes table } else { //do this if code exist in the database: // //code exist in the database $sql = "SELECT LOT_CODE, TERMINAL_ID, ACTIVE FROM DEPENDENCY WHERE LOT_CODE='$lotCode' AND TERMINAL_ID='1' AND ACTIVE=TRUE"; $result = mysql_query($sql, $con); $total = mysql_num_rows($result); if ($total <= 0) { echo "0"; // continue to transact } else { // query the last terminal it was used $sql = "SELECT LOT_CODE, TERMINAL_ID, ACTIVE FROM DEPENDENCY WHERE LOT_CODE='$lotCode' AND ACTIVE=TRUE ORDER BY DATE_ENTRY DESC LIMIT 1"; $result = mysql_query($sql, $con); $row = mysql_fetch_array($result); $total = mysql_num_rows($result); echo $row['TERMINAL_ID'] ; // already used here - me nakita // GET THE LAST TERMINAL NUMBER ACTIVE ADD 1 HERE TO DISPLAY WHICH TERMINAL TO GO } } } } //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> elseif ($terminalNo == "4") { if ($lotCode != "") { $sql = "SELECT BARCODE FROM LEGALCODES WHERE BARCODE='$lotCode'"; $result = mysql_query($sql, $con); $total = mysql_num_rows($result); if ($total <= 0) { echo "X"; // X - for non existent in the mes table } else { //if downgrade is checked do this : if ($downMode == "true") { $advanceTerminal = ((integer)($terminalNo) + 1); $advanceTerminal = (string)($advanceTerminal); $preTerminal = ((integer)($terminalNo) - 1); $preTerminal = (string)($preTerminal); //query if the lot code exist in advance terminal .. $sql = "SELECT LOT_CODE, TERMINAL_ID, ACTIVE FROM DEPENDENCY WHERE LOT_CODE='$lotCode' AND TERMINAL_ID='$advanceTerminal' AND ACTIVE=TRUE"; $result = mysql_query($sql, $con); $total = mysql_num_rows($result); if ($total <= 0) { // check naman kung wala sa naunang terminal $sql = "SELECT LOT_CODE, TERMINAL_ID, ACTIVE FROM DEPENDENCY WHERE LOT_CODE='$lotCode' AND TERMINAL_ID='$preTerminal' AND ACTIVE=TRUE"; $result = mysql_query($sql, $con); $total = mysql_num_rows($result); if ($total <= 0) { $sql = "SELECT LOT_CODE, TERMINAL_ID, ACTIVE FROM DEPENDENCY WHERE LOT_CODE='$lotCode' AND ACTIVE= TRUE ORDER BY TERMINAL_ID DESC LIMIT 1"; $result = mysql_query($sql, $con); $row = mysql_fetch_array($result); $total = mysql_num_rows($result); if ($total <= 0) { // NO RECORDS FOUND GO TO TERMINAL 1 == optional echo "notran"; } else { echo $row['TERMINAL_ID'] ; } } else { $sql = "SELECT LOT_CODE, TERMINAL_ID, ACTIVE FROM DEPENDENCY WHERE LOT_CODE='$lotCode' AND TERMINAL_ID='$terminalNo' AND ACTIVE=TRUE"; $result = mysql_query($sql, $con); $total = mysql_num_rows($result); if ($total <= 0 || $total >= 0) { echo "G"; } } } else { $sql = "SELECT LOT_CODE, TERMINAL_ID, ACTIVE FROM DEPENDENCY WHERE LOT_CODE='$lotCode' AND ACTIVE= TRUE ORDER BY TERMINAL_ID DESC LIMIT 1"; $result = mysql_query($sql, $con); $row = mysql_fetch_array($result); $total = mysql_num_rows($result); echo $row['TERMINAL_ID'] ; } } else { //query if the lot code exist in this terminal .. $sql = "SELECT LOT_CODE, TERMINAL_ID, ACTIVE FROM DEPENDENCY WHERE LOT_CODE='$lotCode' AND TERMINAL_ID='$terminalNo' AND ACTIVE=TRUE"; $result = mysql_query($sql, $con); $total = mysql_num_rows($result); if ($total <= 0) { // wala nakita - then tsek if nag exist sa terminal na sinundan $preTerminal = ((integer)($terminalNo) - 1); $preTerminal = (string)($preTerminal); //then tsek if nag exist sa terminal na sinundan $sql = "SELECT LOT_CODE, TERMINAL_ID, ACTIVE FROM DEPENDENCY WHERE LOT_CODE='$lotCode' AND TERMINAL_ID='$preTerminal' AND ACTIVE=TRUE"; $result = mysql_query($sql, $con); $total = mysql_num_rows($result); if ($total <= 0) { // walang nakita sa mga naunang terminal // do this if no previous transaction with pre requisite process // query the last terminal it was used $sql = "SELECT LOT_CODE, TERMINAL_ID, ACTIVE FROM DEPENDENCY WHERE LOT_CODE='$lotCode' AND ACTIVE= TRUE ORDER BY TERMINAL_ID DESC LIMIT 1"; $result = mysql_query($sql, $con); $row = mysql_fetch_array($result); $total = mysql_num_rows($result); // $row = mysql_fetch_array($result); if ($total <= 0) { // NO RECORDS FOUND GO TO TERMINAL 1 == optional echo "notran"; } else { echo $row['TERMINAL_ID']; // GET THE LAST TERMINAL NUMBER ACTIVE ADD 1 HERE TO DISPLAY WHICH TERMINAL TO GO } } else { echo "G"; } } else { //me record na nakita sa terminal na pinag transakan // query the last terminal it was used $sql = "SELECT LOT_CODE, TERMINAL_ID, ACTIVE FROM DEPENDENCY WHERE LOT_CODE='$lotCode' AND ACTIVE=TRUE ORDER BY TERMINAL_ID DESC LIMIT 1"; $result = mysql_query($sql, $con); $row = mysql_fetch_array($result); $total = mysql_num_rows($result); echo $row['TERMINAL_ID'] ; // already used here - me nakita // GET THE LAST TERMINAL NUMBER ACTIVE ADD 1 HERE TO DISPLAY WHICH TERMINAL TO GO } } // here is the terminator of else in downgrade } } //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> if ($lotCodeDownGrade != "") { $sql = "SELECT BARCODE FROM LEGALCODES WHERE BARCODE='$lotCodeDownGrade'"; $result = mysql_query($sql, $con); $total = mysql_num_rows($result); if ($total <= 0) { echo "X"; // X - for non existent in the mes table } else { //do this if code exist in the database: // //code exist in the database $sql = "SELECT LOT_CODE, TERMINAL_ID, ACTIVE FROM DEPENDENCY WHERE LOT_CODE='$lotCodeDownGrade' AND ACTIVE=TRUE"; $result = mysql_query($sql, $con); $total = mysql_num_rows($result); if ($total <= 0) { echo "0"; // continue to transact } else { // query the last terminal it was used $sql = "SELECT LOT_CODE, TERMINAL_ID, ACTIVE FROM DEPENDENCY WHERE LOT_CODE='$lotCodeDownGrade' AND ACTIVE=TRUE ORDER BY TERMINAL_ID DESC LIMIT 1"; $result = mysql_query($sql, $con); $row = mysql_fetch_array($result); $total = mysql_num_rows($result); echo $row['TERMINAL_ID'] ; // already used here - me nakita // GET THE LAST TERMINAL NUMBER ACTIVE ADD 1 HERE TO DISPLAY WHICH TERMINAL TO GO } } } } //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> else { if ($lotCode != "") { $sql = "SELECT BARCODE FROM LEGALCODES WHERE BARCODE='$lotCode'"; $result = mysql_query($sql, $con); $total = mysql_num_rows($result); if ($total <= 0) { echo "X"; // X - for non existent in the mes table } else { //query if the lot code exist in this terminal .. $sql = "SELECT LOT_CODE, TERMINAL_ID, ACTIVE FROM DEPENDENCY WHERE LOT_CODE='$lotCode' AND TERMINAL_ID='$terminalNo' AND ACTIVE=TRUE"; $result = mysql_query($sql, $con); $total = mysql_num_rows($result); if ($total <= 0) { // wala nakita - then tsek if nag exist sa terminal na sinundan $preTerminal = ((integer)($terminalNo) - 1); $preTerminal = (string)($preTerminal); //then tsek if nag exist sa terminal na sinundan $sql = "SELECT LOT_CODE, TERMINAL_ID, ACTIVE FROM DEPENDENCY WHERE LOT_CODE='$lotCode' AND TERMINAL_ID='$preTerminal' AND ACTIVE=TRUE"; $result = mysql_query($sql, $con); $total = mysql_num_rows($result); if ($total <= 0) { // walang nakita sa mga naunang terminal // do this if no previous transaction with pre requisite process // query the last terminal it was used $sql = "SELECT LOT_CODE, TERMINAL_ID, ACTIVE FROM DEPENDENCY WHERE LOT_CODE='$lotCode' AND ACTIVE=TRUE ORDER BY TERMINAL_ID DESC LIMIT 1"; $result = mysql_query($sql, $con); $row = mysql_fetch_array($result); $total = mysql_num_rows($result); if ($total <= 0) { // NO RECORDS FOUND GO TO TERMINAL 1 == optional echo "notran"; } else { echo $row['TERMINAL_ID']; // GET THE LAST TERMINAL NUMBER ACTIVE ADD 1 HERE TO DISPLAY WHICH TERMINAL TO GO } } else { echo "G"; } } else { //me record na nakita sa terminal na pinag transakan // query the last terminal it was used $sql = "SELECT LOT_CODE, TERMINAL_ID, ACTIVE FROM DEPENDENCY WHERE LOT_CODE='$lotCode' AND ACTIVE= TRUE ORDER BY TERMINAL_ID DESC LIMIT 1"; $result = mysql_query($sql, $con); $row = mysql_fetch_array($result); $total = mysql_num_rows($result); echo $row['TERMINAL_ID'] ; // already used here - me nakita // GET THE LAST TERMINAL NUMBER ACTIVE ADD 1 HERE TO DISPLAY WHICH TERMINAL TO GO } } } } mysql_close($con); ?> Code: [Select] function unUsedLotId(txtElemID){ var txtElemID_Active = txtElemID; //alert("VV" + txtElemID_Active.value + "VV" ); responsePHP = "no_reply"; changeFocus = false; var termNo = terminalNo(); ajaxRequest = remoteRequestObject(); ajaxRequest.onreadystatechange = function(){ if (ajaxRequest.readyState==4 && ajaxRequest.status==200) { // var result = ajaxRequest.responseText; responsePHP = ajaxRequest.responseText; //alert(responsePHP) // if (result=="1") { result = "Already used Tag";} // if (result=="0") { result = "Tag ok";} // if (result=="G") { result = "Tag ok";} // if (result=="B") { result = "Incomplete Process";} // var resultStr = (result=="1") ? 'Tag used or incomplete prerequisites' : 'Tag unused'; if (responsePHP == "failed") { txtElemID_Active.disabled = false; txtElemID_Active.value = ""; txtElemID_Active.focus(); notify("Report to MIS<br /> Please scan again."); } //------------------------------added by rhoda for integration-------------------------------------------------- /* else if (responsePHP == "C"){ notify("CCCC"); if (txtElemID_Active.disabled) { txtElemID_Active.disabled = false; } txtElemID_Active.value = ""; txtElemID_Active.focus(); } */ //-------------------------------------------------------------------------------- else if (responsePHP == "X") { //result = "Lot ID invalid."; //responsePHP = "Lot ID invalid."; notify("Lot ID invalid. Scan Again."); if (txtElemID_Active.disabled) { txtElemID_Active.disabled = false; } txtElemID_Active.value = ""; txtElemID_Active.focus(); } //-------------------------------------------------------------------------------- else if (responsePHP =="0" || responsePHP =="G"){ if (txtElemID_Name == "txtLotCode") { window.LotID = (txtElemID_Active.value) } if (txtElemID_Name == "txtLotCodeDownGrade") { window.LotID_Down = (txtElemID_Active.value) } strip(txtElemID_Active) if (termNo == "1") { isSelected('txtLotCode', 'selWeight_MachineID'); } if (termNo == "2" || termNo == "3") { isSelected('txtLotCode', 'txtKitWeight'); } if (termNo == "4" || termNo == "5" || termNo == "6" || termNo == "7") { //////////////////////////////// downgrade modification /////////////////////////////////////// if (termNo == "4") { //alert(termNo) var chkDownGrade = document.getElementById('chkDownGrade') if (chkDownGrade.checked == 1) { //alert("here") if (txtElemID_Name == 'txtLotCode') { isSelected('txtLotCode', 'txtLotCodeDownGrade'); } if (txtElemID_Name == 'txtLotCodeDownGrade') { isSelected('txtLotCodeDownGrade', 'selMachineID'); } } else { //alert("here") if (txtElemID_Name == 'txtLotCode') { isSelected('txtLotCode', 'selMachineID'); } } } else { isSelected('txtLotCode', 'selMachineID'); } //////////////////////////////////////////////////////////////////////////////////////// } if (document.getElementById('notice')!== null) { document.getElementsByTagName('body')[0].removeChild(document.getElementById('notice')) //>> clear the box } } //-------------------------------------------------------------------------------- else if (responsePHP == "notran") { var mensahe1 = "Please return to<br /><span style='font-size:30px;'>Chemical Weighing<br /> or Supervisor</span>"; notify(mensahe1); if (txtElemID_Active.disabled) { txtElemID_Active.disabled = false; } txtElemID_Active.value = ""; txtElemID_Active.focus(); } //-------------------------------------------------------------------------------- else { /* responsePHP == "1" || responsePHP == "B") { do this if tag is used in this terminal if (responsePHP == "1") { result = "Already used Lot ID"; responsePHP = "Already used Lot ID"; notify("Already used Lot ID.<br />Scan again."); } else if (responsePHP == "B") { // result = "Incomplete Transaction Process"; // responsePHP = "Incomplete Transaction Process"; notify("Incomplete Transaction Process.<br />Scan again."); } */ var mensahe1 = "Last Process: <span style='font-size:30px;'> Terminal " + responsePHP + "</span><br /><br />"; var mensahe2 = "Pls. Proceed: <span style='font-size:30px;'> Terminal " + (parseInt(responsePHP) + 1) + "</span>"; notify(mensahe1 + mensahe2); // notify("Incomplete Transaction Process.<br />Scan again."); if (txtElemID_Active.disabled) { txtElemID_Active.disabled = false; } txtElemID_Active.value = ""; txtElemID_Active.focus(); } //-------------------------------------------------------------------------------- } } var txtElemID_Name = txtElemID_Active.id; if (termNo == "4") { var downGrade = document.getElementById('chkDownGrade').checked; var str = txtElemID_Active.value + "&n=" + termNo + "&down=" + downGrade; } else { var str = txtElemID_Active.value + "&n=" + termNo; } if (txtElemID_Name == "txtLotCode") { //alert(txtElemID_Name) var url = "verifyLotId.php?normal=" + str; } if (txtElemID_Name == "txtLotCodeDownGrade") { //alert(txtElemID_Name) var url = "verifyLotId.php?downgrade=" + str; } ajaxRequest.open("GET", url, true); // force i.e. not to cache ajaxRequest.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"); //-------------------------------------------------- ajaxRequest.send(null); ajaxTimeOut = window.setTimeout("timeOut('" + txtElemID_Name + "');", 6000); } This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=348953.0 i am trying to set user status as offline when user close browser but i am facing a problem ... i am calling a function when body unload which will set guest user status to "0" when user close the browser but it not working ... it execute php before function is called.. any idea why this is happening ...please help it's making me crazy As the topic sais i have a problem trying to send variables to a javascript popup window, i think the problem is on line 38. I would very much appreciate some help Code: [Select] <html> <head> <script type="text/javascript"> function newPopup(url) { popupWindow = window.open(url,'popUpWindow','height=700,width=400,left=10,top=10,resizable=no,scrollbars=no,toolbar=yes,menubar=no,location=no,directories=no,status=yes') } </script> </head> <?php error_reporting(E_ALL); require_once 'GameQ.php'; $servers = array( 'server 1' => array('cs', 'd2o.warzone.nu', '27015'), 'server 2' => array('cs', 'd2o.warzone.nu', '27017'), 'server 3' => array('cs', 'wc3.warzone.nu', '27017'), 'server 4' => array('cs', 'aim.warzone.nu', '27015'), 'server 5' => array('cs', '83.255.249.204', '27025'), 'server 6' => array('tf2', 'tf2.warzone.nu', '27015'), 'server 7' => array('tf2', '83.255.249.200', '27015'), 'server 9' => array('cssource', 'css.warzone.nu', '27015'), 'server 10' => array('cssource', 'css.warzone.nu', '27017') ); $gq = new GameQ(); $gq->addServers($servers); $gq->setOption('timeout', 200); $gq->setFilter('normalise'); $gq->setFilter('sortplayers', 'gq_ping'); $results = $gq->requestData(); echo "<a href='steam://connect/d2o.warzone.nu:27015'>" . $results["server 1"]['gq_hostname'] . "</a><p>"; echo $results["server 1"]['gq_mapname'] . "<br>"; echo $results["server 1"]['gq_numplayers'] . "/" . $results["server 1"]['gq_maxplayers']; ?> // I think the problem is the line below this one <a href='JavaScript:newPopup("players.php?address=<?php echo="$results['server 1']['gq_address']"; ?>&port=<?php echo="$results['server 1']['gq_port']"; ?>");'> players online </a>"; <?php echo "<p><p>"; echo "<a href='steam://connect/d2o.warzone.nu:27017'>" . $results["server 2"]['gq_hostname'] . "</a><p>"; echo $results["server 2"]['gq_mapname'] . "<br>"; echo $results["server 2"]['gq_numplayers'] . "/" . $results["server 2"]['gq_maxplayers'] . " players online <p>"; echo "<p><p>"; echo "<a href='steam://connect/wc3.warzone.nu:27017'>" . $results["server 3"]['gq_hostname'] . "</a><p>"; echo $results["server 3"]['gq_mapname'] . "<br>"; echo $results["server 3"]['gq_numplayers'] . "/" . $results["server 3"]['gq_maxplayers'] . " players online <p>"; echo "<p><p>"; echo "<a href='steam://connect/aim.warzone.nu:27015'>" . $results["server 4"]['gq_hostname'] . "</a><p>"; echo $results["server 4"]['gq_mapname'] . "<br>"; echo $results["server 4"]['gq_numplayers'] . "/" . $results["server 4"]['gq_maxplayers'] . " players online <p>"; echo "<p><p>"; echo "<a href='steam://connect/83.255.249.204:27025'>" . $results["server 5"]['gq_hostname'] . "</a><p>"; echo $results["server 5"]['gq_mapname'] . "<br>"; echo $results["server 5"]['gq_numplayers'] . "/" . $results["server 5"]['gq_maxplayers'] . " players online <p>"; echo "<p><p>"; echo "<a href='steam://connect/tf2.warzone.nu:27015'>" . $results["server 6"]['gq_hostname'] . "</a><p>"; echo $results["server 6"]['gq_mapname'] . "<br>"; echo $results["server 6"]['gq_numplayers'] . "/" . $results["server 6"]['gq_maxplayers'] . " players online <p>"; echo "<p><p>"; echo "<a href='steam://connect/83.255.249.200:27015'>" . $results["server 7"]['gq_hostname'] . "</a><p>"; echo $results["server 7"]['gq_mapname'] . "<br>"; echo $results["server 7"]['gq_numplayers'] . "/" . $results["server 7"]['gq_maxplayers'] . " players online <p>"; echo "<p><p>"; echo "<a href='steam://connect/tf2.warzone.nu:27015'>" . $results["server 8"]['gq_hostname'] . "</a><p>"; echo $results["server 8"]['gq_mapname'] . "<br>"; echo $results["server 8"]['gq_numplayers'] . "/" . $results["server 8"]['gq_maxplayers'] . " players online <p>"; echo "<p><p>"; echo "<a href='steam://connect/css.warzone.nu:27015'>" . $results["server 9"]['gq_hostname'] . "</a><p>"; echo $results["server 9"]['gq_mapname'] . "<br>"; echo $results["server 9"]['gq_numplayers'] . "/" . $results["server 9"]['gq_maxplayers'] . " players online <p>"; echo "<p><p>"; echo "<a href='steam://connect/css.warzone.nu:27017'>" . $results["server 10"]['gq_hostname'] . "</a><p>"; echo $results["server 10"]['gq_mapname'] . "<br>"; echo $results["server 10"]['gq_numplayers'] . "/" . $results["server 10"]['gq_maxplayers'] . " players online <p>"; ?> </html> This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=316889.0 Guys thanks for helping me solve the problem i had but now i have another problem and i am lost. i have included the code below for you to have overview.
This is the code:
<table style="width:100%; margin-left:auto; margin-right:auto"> Hi guys... i want to do registration of text box which are created dynamically.. please help me how can i do registration? I need some help. I'm having trouble calling a javascript function from a php script Code: [Select] <?php include ('security.inc'); include ('head.inc'); echo ' <table class="menutable"> <tr> <td nowrap> <div id="sidemenu" style="display:block;"> <ul id="navbar">'; // database-driven menu groups // get the menu items and groups that this user has access to if (!isset($_SESSION['usergroupsin']) || $_SESSION['usergroupsin']==''){ $menurs=array(); } else { $sql="SELECT mg_name, mg_desc, mi_name, mi_desc, mi_link, mi_external_link, mgg_gr_id, mig_gr_id FROM tbl_menu_items INNER JOIN tbl_menu_groups ON mi_mg_id=mg_id AND mg_active='y' LEFT JOIN tbl_menu_groups_groups ON mgg_mg_id=mg_id AND mgg_active='y' LEFT JOIN tbl_menu_items_groups ON mig_mi_id=mi_id AND mig_active='y' WHERE ( mgg_gr_id IN (".$_SESSION['usergroupsin'].") OR mig_gr_id IN (".$_SESSION['usergroupsin'].") OR mi_secure='n' ) AND mi_active='y' AND mg_left_menu='y' GROUP BY mg_name, mg_desc, mi_name, mi_desc, mi_link, mi_external_link ORDER BY mg_sort, mi_sort"; $menurs=myload($sql); } $last_mg_name=''; if (count($menurs)>0){ foreach ($menurs as $m){ // show the group heading if we haven't already shown it if ($m['mg_name']<>$last_mg_name){ echo '<li><strong> <br>'.$m['mg_name'].'</strong></li>'; $last_mg_name=$m['mg_name']; } // determine whether this is a system link or not if ($m['mi_external_link']=='y'){ $thisurl=$m['mi_link']; } else { $thisurl=$config['system_url_root'].$m['mi_link']; } echo '<li><a title="'.$m['mi_desc'].'" href="'.$thisurl.'"><strong> - '.$m ['mi_name'].'</strong></a></li>'; } } echo ' </ul> </div> </td> [b]<input class="button" type="button" value="Hide Menu" onclick="setTable('sidemenu');return true">[/b] <td width="100%"> <div id="mainwindow"> <!-- BEGIN PAGE CONTENT --> '; ?> My javacscipt function is in the head.inc. I can post that if needed. The bolded part is what I'm having trouble with. Specifically, the onclick. Without that, my script works, if I have the onclick in there, I get a blank page. I'm trying to hide/show the div=sidemenu. If anybody has any suggestions, I'm open to it. Hello, I'm currently working on a gaming website, however there is an issue. I have a custom YouTube player, however I need to get the link dependant on a value from the database. The ID is in the URL, which is then collecting the youtube video URL from the database. However, I'm trying to then echo that back out into the Javascript video. On my normal page, that plays the Video is: Header: Styles.css & youTubeEmbed-jquery-1.0.css need to be added. Code: [Select] <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Having Fun With YouTube's API - Making a Custom Video Player | Tutorialzine Demo</title> <link rel="stylesheet" type="text/css" href="styles.css" /> <link rel="stylesheet" type="text/css" href="video_player/youTubeEmbed/youTubeEmbed-jquery-1.0.css" /> </head> Footer: All of that needs to be added. Code: [Select] <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script src="jquery.swfobject.1-1-1.min.js"></script> <script src="youTubeEmbed/youTubeEmbed-jquery-1.0.js"></script> <script type="text/javascript"> $(document).ready(function(){ $('#player').youTubeEmbed("VID LINK FROM DB SHOULD BE HERE"); $('form').submit(function(){ $('#player').youTubeEmbed({ video : 'VID LINK FROM DB SHOULD BE HERE', width : 640, // Height is calculated automatically progressBar : false // Hide the progress bar }); }); }); </script> </body> </html> Code: [Select] <?php include("config.php"); $host = $config['Site']['Host']; $username = $config['Site']['Username']; $password = $config['Site']['Password']; $database = $config['Site']['Database']; $name = $config['Site']['Name']; $favicon = $config['Site']['Favicon']; mysql_connect($host, $username, $password) or die(mysql_error()); mysql_select_db($database) or die(mysql_error()); function getVid() { $vID = $_GET['vID']; $sQuery = "SELECT * FROM vids WHERE id='$vID'"; $sResult = mysql_query($sQuery); while($row = mysql_fetch_array($sResult)) { $vID = $row['url']; } } ?> Above is the Global.php, and that's where the problem lies, whenever I try to insert the peices required, nothing happens and the video doesn't show. Could anybody please help?! I'm trying to have a javascript confirm box pop up and confirm the intention to delete a record in a database. I think I'm having trouble calling the function within my PHP code, but not sure what exactly is wrong. The status bar shows something like "javascript:checkDelete(100, Title)" when I hover over the link and that seems right but nothing occurs when I click on it. Here is my code: Javascript Code: [Select] <script language="Javascript"> function checkDelete(b,Title){ var del=confirm("Are you sure you want to delete " + Title + " from the Database?"); if (del){ document.location="delete.php?mID=" + b + "&Title=" + Title; } } </script> PHP echo "<td><a href='Javascript:checkDelete(" . $row['mID'] . "," . $row['Title'] . ")'>"; echo "<img border=0 src='images/delete.gif'>" . "</a></td></tr>"; Anyone see my error? well i got more questions since i started at javascript and now im currently practicing php my question is whats the equivalent of this lines of codes to php language? document.getElementById("txt1").value <input type="button" name="one" id="one" value="1" onclick="javascript:getvalue(1);"\> == well what i mean is can i pass value to php functions every time i click it? just like calculators OT: can some1 help me translating my js calcu codes to php ones? document.getElementById("txt1").value this is my main problem i cant display the buttons i click hi. i have a page B which has an image on it. When the page loads i want it to auto click on that image. I wrote the code below but it does not autoclick. can you please help? <script language="javascript"> function autoClick() { document.getElementById('thisLink').click(); } </script> <php> $visitpage = "http://mywebsitei.com/wp-content/uploads/12345.jpg"; <div style="text-align: center;" ######="setTimeout('autoClick();',3000);"> <a href=<?php echo $visitpage ?> rel="lightbox" > <img src=<?php echo $visitpage; ?> alt=""/></a> </div> </php> Hello all, i need your help on this.
I don´t know if it´s possible, and if possible, i don´t know how to do it.
I catch visitors country code using javascript in a variable called "country".
Then, i need to php include diferent files based on that country code, like:
if country == UK
include header_uk.php
else if country == US
include header_us.php
else if country == BR
include header_br.php
else
include header.php
I don´t know nothing about coding, this is just an example.
I don´t have another way of catching visitors country without javascript.
Is this possible?
Thanks in advance.
Edited by vascorama, 17 August 2014 - 01:49 PM. |