AW.HTTP.Request
My problem is getting an AW.INPUT text box, that is displaying a "document number" retrieved from a database, to refresh and get the next available number after I have posted a AW.HTTP.Request, which updates a database & increments the document number.
I have a php function that gets the next available document number but I can't work out hot to get that to refresh, So... I have decided to try and sumbit the page after the AW.HTTP.Request.
No matter what I try I can not work out how to do it succesfully?
If I insert the submit after the AW.HTTP Request, it process the alert box with the response and updates the database, but fails to submit.
If I Insert the submit in the "Invoice.onControlClicked" confirm script, it sumbits and updates the database, but the page submit is before the update and the document number stays the same unless I manually submit...
Please help?
Here is a page with the some example code (with the submit in the Invoice.onControlClicked): -
I have a php function that gets the next available document number but I can't work out hot to get that to refresh, So... I have decided to try and sumbit the page after the AW.HTTP.Request.
No matter what I try I can not work out how to do it succesfully?
If I insert the submit after the AW.HTTP Request, it process the alert box with the response and updates the database, but fails to submit.
If I Insert the submit in the "Invoice.onControlClicked" confirm script, it sumbits and updates the database, but the page submit is before the update and the document number stays the same unless I manually submit...
Please help?
Here is a page with the some example code (with the submit in the Invoice.onControlClicked): -
<?php include ("dbconnect.php"); ?>
<?Php include ("functions.inc.php"); ?>
<Body>
<script src="runtime/lib/aw.js"></script>
<link href="runtime/styles/xp/aw.css" rel="stylesheet"></link>
<form name="form" action="test.php">
<fieldset>
<legend>Company Details</legend>
<table>
<tr><td>Company Name:</td><td>
<script type="text/javascript">
var companyName = new AW.UI.Input;
companyName.setStyle("width","150px");
document.write(companyName);
</script></tr>
<tr><td>Document:</td><td>
<script type="text/javascript">
var nextdoc = '<?php DocumentNext() ?>'
var doc = new AW.UI.Input;
doc.setControlText(nextdoc);
doc.setStyle("width","60px");
document.write(doc);
</script></tr>
<tr><td>Description:</td><td>
<script type="text/javascript">
var desc = new AW.UI.Input;
desc.setStyle("width","200px");
document.write(doc);
</script></tr>
</table>
</fieldset>
</form>
</Body>
<script>
var Invoice= new AW.UI.Button;
Invoice.setControlText("Invoice");
Invoice.setControlValue(5);
Invoice.onControlClicked = function(){
if (confirm("Are you sure you want to increment the document number?")) {
alert("You were sure!")
Invoice.setControlValue(4);
document.form.submit();
}
else
{
alert("You were not sure!")
}
}
var Submit = new AW.UI.Button;
Submit.setControlText("Submit")
Submit.onControlClicked = function(){
document.form.submit();
}
Invoice.onControlValueChanged = function(){
var g = new AW.HTTP.Request;
var document = '<?Php DocumentNextInv() ?>'
g.setUR("HTTPResponse.php");
g.setRequestMethod("POST");
g.setParameter("Document", document);
g.request();
g.response = function(data){
alert(data); // process response data
}
}
document.write(Invoice);
document.write(Submit);
</script>
Jez
April 21,