fj1200 Posted September 17, 2009 Share Posted September 17, 2009 I have this posted on the Javascript page but wonder if ajax is the solution. I've been playing with it this morning but getting nowhere. function insRow() { var mytable=document.getElementById("advicenote") for (var i=0; i<1; i++){ //add 3 new rows with content to the end of a table var newrow=advicenote.insertRow(-1) //add new row to end of table var newcell=newrow.insertCell(0) //insert new cell to row newcell.innerHTML='<SELECT name="JOBNAME"><?php while($nt=mssql_fetch_array($result3)) { echo "<option value='".$SITE_ID.".".$nt['JOB_NAME'].".".$nt['JOB_DESCRIPTION'].".".$JOBTYPE."'>".$nt['JOB_DESCRIPTION']."</option>"; } ?></select>'; var newcell=newrow.insertCell(1) //insert new cell to row newcell.innerHTML='<input name=\"depot_edition">'; var newcell=newrow.insertCell(2) //insert new cell to row newcell.innerHTML='<input name=\"copies_bundle\">'; var newcell=newrow.insertCell(3) //insert new cell to row newcell.innerHTML='<input name=\"bundles_std\">'; var newcell=newrow.insertCell(4) //insert new cell to row newcell.innerHTML='<input name=\"bundles_odds\">'; var newcell=newrow.insertCell(5) //insert new cell to row newcell.innerHTML='<input name=\"pallet_count\">'; } } </script> The above code adds a row of input boxes to a page. BUT - the first box is a drop-down list of running jobs that needs to be populated from the SQL Server production database at time of clicking the Add button. Tried all sorts, but it's not working. The query works fine though. I'm a bit of a noob to JS and Ajax, so willing to learn. Been reading Tutorials all morning. Any help gratefuly recieved, Quote Link to comment Share on other sites More sharing options...
fj1200 Posted September 17, 2009 Author Share Posted September 17, 2009 I have now got a working ajax drop-down, does everything I need EXCEPT - I can't get it to sit in the first cell. Tried everything I can think of, tried loads of other people's ideas, just not working. function printpage(){ window.print(); } //--> function insRow() { var ajaxRequest; // The variable that makes Ajax possible! var mytable=document.getElementById("advicenote") for (var i=0; i<1; i++){ //add 3 new rows with content to the end of a table var newrow=advicenote.insertRow(-1) //add new row to end of table ajaxRequest.open("GET","ajax-advicenote.php", true); ajaxRequest.send(null); ajaxRequest.onreadystatechange = function(){ if(ajaxRequest.readyState == 4){ var ajaxDisplay = document.getElementById('job'); ajaxDisplay.innerHTML = ajaxRequest.responseText; } } ajaxRequest.open("GET","ajax-example.php", true); ajaxRequest.send(null); } } var newcell=newrow.insertCell(0) //insert new cell to row newcell.innerHTML= ajaxRequest.responseText; I'm at a bit of a loss as to know what to do. Can I give the newcell an id so I can reference it and so get the ajax response into it? My first time with ajax so be nice. Taken me all day pretty much to get this far! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.