Jump to content

stockton

Members
  • Posts

    319
  • Joined

  • Last visited

    Never

Everything posted by stockton

  1. Thank you. As you say innerHTML solved the immediate problem.
  2. I have added an alert to the scenario giving the following:- my Ajax as follows:- function handleIssueTicketsResponse() { if(http.readyState == 4 && http.status == 200) { var IssuedValue = document.getElementById("IssuedValue").value; var OutstandingValue = document.getElementById("OutstandingValue").value; alert("Before IssuedValue: "+IssuedValue+" OutstandingValue: "+OutstandingValue); and the alert reports both IssuedValue as well as OutstandingValue as undefined. Therefore the problem lies in the getElementById() but is the problem my use of getElementById() or is the problem in my definition of these fields in my web page. These fields are defined as:- <div style="position:relative;" id="IssuedValue";><b>Issued value.</b></div> <div style="position:relative;" id="OutstandingValue";><b>Outstanding value.</b></div>
  3. Do you have a recommendation on how I should identify what these values are? Those two values are ex a MSSQL database. The web page calls Ajax to repopulate its fields by calling a PHP program. This step works fine. Next step is when the user clicks an install button Ajax is again called which in turn calls a PHP script on the server to update the database and on return from the PHP to Ajax I wish to alter those two fields so that I can call a Javascript function to print the displayed data. However at this point the data on the screen is what is going to happen and I need this to change(the database has been updated) to what has happened. IssuedValue needs to be updated to what was altered in the database. BTW The database is reflecting the correct information. So now the only issue is to get the printout to reflect the correct data.
  4. Please tell me why I get a NaN returned in my Javascript from :- IssuedValue = document.getElementById("IssuedValue").value; OutstandingValue = document.getElementById("OutstandingValue").value; document.getElementById("IssuedValue").value = IssuedValue + OutstandingValue; document.getElementById("IssuedValue").value ends up being a NaN, why?
  5. How come in other forums I can mark a topic as solved whereas in Ajax I cannot or at least I cannot find out how to mark a topic solved?
  6. I have been asked to enhance a system running on Windows that would display images for a given length of time one after the other in sequence. The system currently does the necessary display but now the user wants to enhance it with the ability of giving each advert a start and stop datetime. ie Do not display before start date and do not display after stop date. This, of course, is easy to do. The question, however, is do I keep these dates in a text file or in MSSQL and if it is kept in Sequel do I then also keep the image in the same table or leave the image where it currently resides in a folder of images? Next question is, even though the image is the whole page, is there any advantage in using Ajax to switch images?
  7. The page looks like:- <html> <title>Adjustments</title> <meta name="author" content="Alf C Stockton"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <!-- <META HTTP-EQUIV="Refresh" CONTENT="60;URL=Administration.php"> --> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="Mon, 22 Jul 2000 11:12:01 GMT"> <link rel="stylesheet" type="text/css" href="./style/style.css"> <script language="JavaScript" type="text/javascript" src="js/ajax.js"></script> <script language="JavaScript" type="text/javascript" src="js/AdjustmentFunctions.js"></script> </head> <?php require_once('includes/configuration.php'); // database connect script & the rest. require_once('includes/logo.inc'); // We 1st check if user has logged on and has authority to add, delete or amend Earn Rates. if ((!$_SESSION['UID']) && (!$_SESSION['Usrname'])) // Not logged in { $Message = sprintf("%s %d <br> Logon to be able to access this task!", __FILE__, __LINE__); trigger_error($Message, E_USER_ERROR); exit; } if ($_SESSION['UserRights'] < { $Message = sprintf("%s %d <br>User %s with access level %d does not have authority for this task!", __FILE__, __LINE__, $_SESSION['Usrname'], $_SESSION['UserRights']); trigger_error($Message, E_USER_ERROR); exit; } ?> <h2>Adjustments</h2> <center> <form name=Adjustments ID=Adjustments method=post action="InsertAdjustment.php?UID=<?php echo $intUserID ?>"> <table border=3 frame=box cellpadding=10 width=40% align=center> <tr> <td>Event:<br></td> <?php DBConnect(); // Connect to Events database // Get todays date. $Datum = date("Y-m-d H:i:s"); /* 2006-03-17 23:22:32 */ $SQL = "SELECT EventID, EventName, LastDrawDate FROM Event WHERE '$Datum'>=EndDate AND '$Datum'<=LastDrawDate"; $rs = mssql_query($SQL, $link); echo "<br /><center><td><select name='Event'>"; $Count = 0; while ($row = mssql_fetch_array($rs)) { $EventID = $row['EventID']; $Message = sprintf("%s", $row['EventName']); $LastDrawDate = $row['LastDrawDate']; echo "<option value=$EventID>$Message</option>"; ++$Count; } if ($Count == 0) { $Message = sprintf("%s %d <br>No events currently applicable!", __FILE__, __LINE__); trigger_error($Message, E_USER_ERROR); exit; } $SQL = "Select EarnTypeID, TableType, EarnType from EarnType"; $rs = mssql_query($SQL, $link); echo '<tr><td>Earn Type :<br /></td>'; echo '<td><select name="Earn Type">'; $Count = 0; while ($row = mssql_fetch_array($rs)) { $EarnTypeID = $row['EarnTypeID']; $EarnType = sprintf("%s", $row['TableType']); echo '<option value='.$EarnTypeID.'>'.$EarnType.'</option>'; ++$Count; } if ($Count == 0) { $Message = sprintf("%s %d <br>No Earn Types defined!", __FILE__, __LINE__); trigger_error($Message, E_USER_ERROR); exit; } DBDisConnect(); ?> </td></tr> <tr><td> <font size=+1>Member No:<br /> Member Name :<br /> Amount :<br /> Reason :<br /></font> </td><td> <input type=text name="CardNumber" id="CardNumber" onBlur="sendRequest('<?php echo $GetName.",".$EventID ?>',this.value)"> <div style="position:relative;" id="MemberName";><b>Member name.</b></div> <div style="position:relative;"><input type=text name="Amount" id="Amount" onBlur="CheckAmount()"></div> <div style="position:relative;"><input type=text name="Reason" id="Reason" onBlur="CheckReason()"></div> </td></tr> </table> </form> <br /> <input type="button" value="Clear" Onclick="ClearAdjustmentForm()"> <input type="button" value="Done" Onclick="AdjustmentDone()"> <input type="button" value="Issue" Onclick="submit_click()"> <input type="button" value="Print" Onclick="print()"> <div id="loadingNode";></div> </center> <?php require_once('includes/tail.inc'); ?> </body> </html> <script language="JavaScript" type="text/javascript"> document.getElementById("Issue").disabled=true; document.getElementById("CardNumber").focus(); </script> and the AdjustmentFunctions.js is in the correct folder and the Ajax scripts work fine.
  8. I have a web page that includes javascript as follows:- <script language="JavaScript" type="text/javascript" src="js/AdjustmentFunctions.js"></script> I have attempted and tested this when coded between the <head> and </head> as well as after the </html> tags and cannot get it to work. The html that should access this are :- <input type="button" value="Clear" Onclick="ClearAdjustmentForm()"> <input type="button" value="Done" Onclick="AdjustmentDone()"> <input type="button" value="Issue" Onclick="submit_click()"> <input type="button" value="Print" Onclick="print()"> and those called functions are all within the AdjustmentFunctions.js file as follows:- function AdjustmentDone() { window.location="Administration.php"; } function ClearAdjustmentForm() { document.getElementById("CardNumber").value = ""; document.getElementById("MemberName").innerHTML = ""; document.getElementById("Amount").value = ""; document.getElementById("Reason").value = ""; document.getElementById("CardNumber").focus(); } function CheckAmount() { if (!document.getElementById("Amount").innerHTML) { alert ("An value must entered"); document.getElementById("Amount").focus(); return false; } else alert(document.getElementById("Amount").innerHTML); } function CheckReason() { if (!document.getElementById("Reason").value = "") { alert ("A reason is required and must be entered"); document.getElementById("Reason").focus(); return false; } if ((document.getElementById("Amount").innerHTML) && (document.getElementById("Reason").value)) { document.getElementById("Issue").disabled=false; } } function submit_click() { var bError = false; var strErrorMsg = ""; document.getElementById("Issue").disabled=false; Adjustments.submit(); } Other pages using javascript work fine. Just this one fails. Please tell me how I got this one wrong?
  9. I used :- ALTER TABLE table-name ADD CONSTRAINT NoDuplicates UNIQUE (Date,MemberNumber) After having read of:- http://www.thescripts.com/forum/thread156807.html and the problem has gone away
  10. I used :- ALTER TABLE table-name ADD CONSTRAINT NoDuplicates UNIQUE (Date,MemberNumber) after having read :- http://www.thescripts.com/forum/thread156807.html
  11. I am not sure that I understand the relationship between Ajax and a php script it calls. Basically what I am trying to understand is how do I return an error message from my PHP script to the Ajax/Javascript that called that PHP and how do I exit that PHP script at the point where the error occurred. Is it as simple as :- echo $Message; exit:
  12. I use the following to call Ajax :- <input type="button" value="Issue" Onclick="sendRequest('.$IssueTickets.",".$Event.',1)"> and sendRequest looks like:- function sendRequest(Mode, Event, CardNumber) { // Call PHP script for requests if (Mode == 2) // ClientData { http.open('get', 'T3.php?EventID='+Event+'&MemberNum='+CardNumber); http.onreadystatechange = handleClientDataResponse; } else if (Mode == 3) // IssueTickets { var KaartNommer = TicketIssue.CardNumber.value; var SlotsValue = document.getElementById("SlotsValue").innerHTML; var SlotsTurnover = document.getElementById("SlotsTurnover").innerHTML; var TablesValue = document.getElementById("TablesValue").innerHTML; var TablesTurnover = document.getElementById("TablesTurnover").innerHTML; var BonusValue = document.getElementById("BonusValue").innerHTML; http.open('get', 'T4.php?EventID='+Event+'&MemberNum='+KaartNommer+'&SlotsValue='+SlotsValue+'&SlotsTurnover='+SlotsTurnover+'&TablesValue='+TablesValue+'&TablesTurnover='+TablesTurnover); http.onreadystatechange = handleIssueTicketsResponse; } http.send(null); } T4.php looks like:- <?php // // T4.php called from T2.php to Issue tickets // Retrieve data from T2 screen and insert into TicketIssued table // require_once('includes/configuration.php'); // database connect script & the rest. DBConnect(); // Connect to Events database $Datum = date("Y-m-d H:i:s"); /* 2006-03-17 23:22:32 */ $Event = strip_tags($_GET['EventID']); $MemberNum = strip_tags($_GET['MemberNum']); $SlotsValue = strip_tags($_GET['SlotsValue']); $ValueSlots = sprintf("%d",$SlotsValue); $SlotsTurnover = strip_tags($_GET['SlotsTurnover']); $TablesValue = strip_tags($_GET['TablesValue']); $ValueTables = sprintf("%d",$TablesValue); $TablesTurnover = strip_tags($_GET['TablesTurnover']); if ($ValueSlots > 0) { $EarnType = "Slots"; $SQL = sprintf("INSERT INTO TicketsIssued (Date, EventID, MemberNumber, EarnType, NumTicketsIssued, Turnover, UserID) VALUES ('%s', '%d', '%s', '%s', '%d', '%d', '%d')", $Datum, $Event, $MemberNum, $EarnType, $SlotsValue, $SlotsTurnover, $_SESSION['UID']); $rs = mssql_query($SQL, $link); if (!$rs) echo get_sql_error($SQL, $link, $sError, $bDebug); } if ($ValueTables > 0) { $EarnType = "Tables"; $SQL = sprintf("INSERT INTO TicketsIssued (Date, EventID, MemberNumber, EarnType, NumTicketsIssued, Turnover, UserID) VALUES ('%s', '%d', '%s', '%s', '%d', '%d', '%d')", $Datum, $Event, $MemberNum, $EarnType, $TablesValue, $TablesTurnover, $_SESSION['UID']); $rs = mssql_query($SQL, $link); if (!$rs) echo get_sql_error($SQL, $link, $sError, $bDebug); } DBDisConnect(); // Disconnect from Events database ?> The problem is that I end up with two identical records in the TicketsIssued table. Note that these records are identical, not one for "Slots" and one for "Tables". Suggestions on what I have done wrong would be gratefully received.
  13. I have a php script on a server that ends up inserting duplicate records and I cannot see why. The code is as follows:- <?php // // T4.php called from T2.php to Issue tickets // Retrieve data from T2 screen and insert into TicketIssued table // require_once('includes/configuration.php'); // database connect script & the rest. DBConnect(); // Connect to Events database $Datum = date("Y-m-d H:i:s"); /* 2006-03-17 23:22:32 */ $Event = strip_tags($_GET['EventID']); $MemberNum = strip_tags($_GET['MemberNum']); $SlotsValue = strip_tags($_GET['SlotsValue']); $ValueSlots = sprintf("%d",$SlotsValue); $SlotsTurnover = strip_tags($_GET['SlotsTurnover']); $TablesValue = strip_tags($_GET['TablesValue']); $ValueTables = sprintf("%d",$TablesValue); $TablesTurnover = strip_tags($_GET['TablesTurnover']); if ($ValueSlots > 0) { $EarnType = "Slots"; $SQL = sprintf("INSERT INTO TicketsIssued (Date, EventID, MemberNumber, EarnType, NumTicketsIssued, Turnover, UserID) VALUES ('%s', '%d', '%s', '%s', '%d', '%d', '%d')", $Datum, $Event, $MemberNum, $EarnType, $SlotsValue, $SlotsTurnover, $_SESSION['UID']); $rs = mssql_query($SQL, $link); if (!$rs) echo get_sql_error($SQL, $link, $sError, $bDebug); } if ($ValueTables > 0) { $EarnType = "Tables"; $SQL = sprintf("INSERT INTO TicketsIssued (Date, EventID, MemberNumber, EarnType, NumTicketsIssued, Turnover, UserID) VALUES ('%s', '%d', '%s', '%s', '%d', '%d', '%d')", $Datum, $Event, $MemberNum, $EarnType, $TablesValue, $TablesTurnover, $_SESSION['UID']); $rs = mssql_query($SQL, $link); if (!$rs) echo get_sql_error($SQL, $link, $sError, $bDebug); } DBDisConnect(); // Disconnect from Events database // echo $SQL; ?> and it is called via Ajax with:- <input type="button" value="Issue" Onclick="sendRequest('.$IssueTickets.",".$Event.',1)"> and sendRequest looks like:- function sendRequest(Mode, Event, CardNumber) { // Call PHP script for requests if (Mode == 2) // ClientData { http.open('get', 'T3.php?EventID='+Event+'&MemberNum='+CardNumber); http.onreadystatechange = handleClientDataResponse; } else if (Mode == 3) // IssueTickets { var KaartNommer = TicketIssue.CardNumber.value; var SlotsValue = document.getElementById("SlotsValue").innerHTML; var SlotsTurnover = document.getElementById("SlotsTurnover").innerHTML; var TablesValue = document.getElementById("TablesValue").innerHTML; var TablesTurnover = document.getElementById("TablesTurnover").innerHTML; var BonusValue = document.getElementById("BonusValue").innerHTML; http.open('get', 'T4.php?EventID='+Event+'&MemberNum='+KaartNommer+'&SlotsValue='+SlotsValue+'&SlotsTurnover='+SlotsTurnover+'&TablesValue='+TablesValue+'&TablesTurnover='+TablesTurnover); http.onreadystatechange = handleIssueTicketsResponse; } http.send(null); } Suggestion as to why I end up with two records that look exactly the same would be gratefully accepted.
  14. I now have my Ajax working OK and now need to print the screen that resulted from that call before clearing same. I have therefore in my function handleIssueTicketsResponse() { if(http.readyState == 4 && http.status == 200) { document.getElementById("loadingNode").innerHTML = ""; // confirm(response); print(); ClearForm(); } else if (http.readyState < 4) { document.getElementById("loadingNode").innerHTML = "Inserting ...."; } } Note print() & then ClearForm(). However I get the screen printed fine but it contains no data. Almost as if I ClearForm() & then print(). Suggestions please.
  15. The solution was to use <database>.<user>.table on the offending select statement
  16. It is a little more complicated than that connect and use DB1 to get data for Stored Procedure connect and use DB2 via Stored Procedure getting data that can be used to get more data from DB1........and this is the one that fails.
  17. I have a php script where I need to access tables in two different MSSQL databases. The scenario is ..... access 1st database to retrieve data that will be used when calling a StoredProcedure within the 2nd database which will return data with which one can access the 1st database to retrieve more data. If I do both calls to the 1st database by hardcoding info from 2nd database all works well but if I access 1st, call StoredProcedure then attempt to do a select back on the 1st I get :- MSSQL returned: Invalid object name 'EarnRate' EarnRate is an existing table in 1st database. Please help.
  18. Thank you for your suggestion. The way I solved it was with:- var Message = "Event....." + Event + "\n"; Message += "CardNumber ......" + CardNumber + "\n"; confirm(Message); to the first called javascript function. This therefore shows that not only did Ajax get called but it was also passed the correct values.
  19. Is there a way to debug/trace Ajax. I have a scenario where the individual bits appear to work but when linked together via Ajax does not produce the required data. I have an HTML page calling JavaScript which via Ajax calls a php application on the server which calls a MSSQL Stored Procedure to retrieve data which should be returned to the client. The server based php, when run on the command line returns the correct data if one adds an echo. Now how to I check that the HTML call to Ajax works and that the Ajax to server based php works?
  20. The solution was:- http.open('get', 'T3.php?EventID='+Event+'&MemberNum='+CardNumber);
  21. After making your suggested change, unless I misunderstood I still get:- Error: missing ) after argument list Source File: http://10.0.0.3/FrontierEvents/js/ajax.js Line: 27, Column: 43 Source Code: http.open('get', 'T3.php?EventID='+Event'&MemberNum='+CardNumber); is the ampersand(&) between Event' and MemberNum correct?
  22. Is it as simple as http.open('get', 'T3.php?EventID='+Event'&MemberNum='+CardNumber); If so thank you very much.
  23. I need to pass two parameters from my Web page to a simple Ajax script. Please tell me how I achieve this? My html looks like:- <input type=text value="" name="CardNumber" id="CardNumber" onChange="sendRequest($Event, this)"> and in my Ajax script I have:- http.open('get', 'T3.php?EventID='+Event'&MemberNum='CardNumber'); and as I get Error: missing ) after argument list Source File: http://10.0.0.3/FrontierEvents/js/ajax.js Line: 27, Column: 43 Source Code: http.open('get', 'T3.php?EventID='+Event'&MemberNum='CardNumber');
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.