giovanni57 Posted January 13, 2015 Share Posted January 13, 2015 Hi all, I'm a super newbie and I got serious problem on programming ... so be patient a bit for my non tech questions. I got a grid where I added a field for enabling the user to the insertion of a quantity on each line. The problem is that all works well but the JS quantity field that is always "empty". OnClick I connect to a PHP program that make a SQL INSERT into a table. All global variables are correct and the quantity result always ''. On attachment there are the two part of code (On Header -> Function OnRecord--> Values) Many thanks indeed Jovanni code_JS_PHP.txt Link to comment Share on other sites More sharing options...
Ingolme Posted January 13, 2015 Share Posted January 13, 2015 You could have put your code in the post, I'll put it here for easier reading: OnRecord if (isset($_POST['id'])){[glo_ProductID] = $_POST['id'];}if (isset($_POST['name'])){[glo_ProductName] = $_POST['name'];}if (isset($_POST['supplier'])){[glo_SupplierID] = $_POST['supplier'];}if (isset($_POST['category'])){[glo_CategoryID] = $_POST['category'];}if (isset($_POST['company'])){[glo_CompanyID] = $_POST['company'];}if (isset($_POST['price'])){[glo_UnitPrice] = $_POST['price'];}if (isset($_POST['quantity'])){[glo_QuantityRow] = $_POST['quantity'];}{col}= "<input type='text' size='6' onchange='myfunction("{ProductID}","{ProductName}","{SupplierID}","{CategoryID}","{CompanyID}","{UnitPrice}", this.value)'>"; OnHeader echo '<script>function myfunction(id, name, supplier, category, company, price, quantity){var xmlhttp;if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safarixmlhttp=new XMLHttpRequest();}else{// code for IE6, IE5xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}xmlhttp.onreadystatechange=function(){if (xmlhttp.readyState==4 && xmlhttp.status==200){console.log(xmlhttp.responseText);}}xmlhttp.open("POST",location.href,true);xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");xmlhttp.send("id="+id+"&name="+name+"&supplier="+s upplier+"&category="+category+"&company="+company+ "&price="+price+"&quantity="+quantity.toString ());</script>'; Is this your real code? You have a few syntax errors. In your PHP, you seem to have substituted variables with square brackets [glo_ProductName] or curly brackets {col}. This isn't PHP syntax. In your Javascript, you have a syntax error right here: "+s upplier+" Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now