Hi there
Im having a bit of a problem getting some Javascript on my html page working properly
This is my Html File
My Php Script definatly works and echos the JSON as expected see hereCode:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script src="javascripts/jquery-1.9.0.js" type="text/javascript"></script> <title>Invoices</title> </head> <body> <Script type="text/javascript"> function GetVehicles(){ $(function(){ var regpart=document.getElementsByName('serstr')[0].value; var items="<option value='0'></option>"; $.getJSON("phpscripts/refreshvehicles.php?a="+regpart,function(data){ var item=""; $.each(data,function(index,item){ items+="<option value='"+item.VehicleId+"'>"+item.Vehicle+"</option>"; }); $("#a1_vehicle").html(items); }); }); } function GetInvoices(sel) { $(function(){ var vid=sel.options[sel.selectedIndex].value; var items="<p>"+vid+"</p><br>"; items+="<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\">"; items+="<tr><th>Invoice Number</th><th>Invoice Date</th><th>Amount</th></tr>"; $.getJSON("phpscripts/getinvoices.php?a="+vid,function(data){ var nitem=""; $.each(data,function(index,nitem){ items+="<tr><td>"+nitem.InvoiceNumber+"</td><td>"+nitem.InvoiceDate+"</td><td>"+nitem.Amount+"</td></tr>"; }); }); items+="</table>" $("#a1_invoice").html(items); }); } </script> <form> <fieldset> <legend>Select Vehicle</legend> <input type='hidden' name='submitted' id='submitted' value='1'/> <label for='serstr' >Vehicle:</label><br> <input type='text' name='serstr' id='serstr' maxlength="50"/><br> <input onclick="GetVehicles()" type='button' name='Filter' value='Filter'/><br> <label for='vehicles' >Vehicle:</label><br> <select onchange="GetInvoices(this)" id="a1_vehicle" name="a1_vehicle"> <option>Default</option> </select> </fieldset> </form> <div id="a1_invoice" name="a1_invoice"> </div> </body> </html>
but id say its the $.getJSON("phpscripts/getinvoices.php?a="+vid,function(data) bit thats not working as i have played around putting other Html Rows in during that section and they haven't come out
Many thanks for any help
Ian



Reply With Quote