Evelyn_Tennessee
New Member
I have two forms on an html page and want to use the first form submit to select from database by php/mysql query and encode using JSON to populate the select options on my second form without leaving the page. The first form and php are sending the array but the second form is not being populated. Not sure what I am missing, any help is appreciated. See html, php and query below...HTML\[code\]<form method="post" action="find.php" id="find" > <div class="input-box"> <label>Last Name</label> <input type="text" name="lname"/> </div> <div class="input-box"> <label>Phone</label> <input type="text" name="phone" /> </div> <div class="submit"> <input type="submit" value="http://stackoverflow.com/questions/14078447/Select" /> </div></form><div><h1>Checkin</h1></div><form method="post" action="checkin.php" id="contact-us"><div id="contact-us-message"></div> <input type="hidden" name="date" id="date" /> <select id="clients" name="clients"> </select> <div class="submit"> <input type="submit" value="http://stackoverflow.com/questions/14078447/Submit" /> </div></form>\[/code\]PHP\[code\]$lastname = $_POST['lname'] ; $number = $_POST['phone'] ; $q = "select Site_ID, FirstName, LastName, Email, Phone, Message, ParentName from ClientInfo where LastName = '$lastname' and Phone = '$number'"; $sql = mysql_query($q); $data = http://stackoverflow.com/questions/14078447/array(); while($row = mysql_fetch_array($sql, true)){ $data[] = $row; }; echo json_encode($data);\[/code\]SCRIPT\[code\]<script type="text/javascript">$("#find").submit(function(){ $.getJSON('checkin.php',function(data){ var items = ''; $.each(data,function(name,value) { items += "<option type='text' value='"+value.Site_ID+"'>"+value.FirstName+" "+value.LastName+" </option>" ; }); $("#clients").append(items); });});</script>\[/code\]EDITOk I fixed the id issue and now when submitting it goes to php page and echos out the correct array. But it should not have left the html page. Anybody know why?ARRAY\[code\][{"Site_ID":"10000007","FirstName":"Drew","LastName"...}]\[/code\]