Rohlan Posted December 30, 2008 Share Posted December 30, 2008 Hello everyone, I'm at a loss here, hence the vague title I'm writing an application which is nearing its first RC version, hurray! Right now I'm going through the things that can be improved on, and one of them is the following: I've got a couple of forms with a "Client" field which is a <select> input. The problem here is that when the client list becomes bigger, so will the select input, something like over nine thousand clients would be scary. So I was thinking of using a paginated table where the user could browse the available clients and upon clicking the client's name, it would fill the form with a value. That much is easy... but whenever the user selects another page, since the page reloads.. all the data previously filled gets erased, which is a pain in the rear. I was thinking of using a GET form to control the pagination, and that way the fields' variables would remain intact. I have yet to implement this but its probably not hard to do... but it sounds extremely clunky and I'm pretty sure there's some fancy solution out there. Any suggestions? Very appreciated. Happy New Year Quote Link to comment https://forums.phpfreaks.com/topic/138934-solved-filling-forms-sorry-a-bit-vague-i-know/ Share on other sites More sharing options...
bluesoul Posted December 30, 2008 Share Posted December 30, 2008 Probably going to take some JavaScript to be somewhat usable. Quote Link to comment https://forums.phpfreaks.com/topic/138934-solved-filling-forms-sorry-a-bit-vague-i-know/#findComment-726608 Share on other sites More sharing options...
Rohlan Posted December 30, 2008 Author Share Posted December 30, 2008 I've searched a lot for a proper solution using javascript/ajax but have come up empty as most of them are really just doing a "virtual" pagination... instead of querying each page, they query all the results then simply proceed to paginated those contents. Though I'm still searching. Thanks for the input. Quote Link to comment https://forums.phpfreaks.com/topic/138934-solved-filling-forms-sorry-a-bit-vague-i-know/#findComment-726612 Share on other sites More sharing options...
xtopolis Posted December 31, 2008 Share Posted December 31, 2008 Use ajax to pop up a suggestion box / pagination box that mimics an Iframe in a sense... Then you could have the names be clickable and have them copy themselves to the client box or w/e... Depends if you allow multiple names, or whatever.. Use ajax so you don't have to go between pages, unless Ajax is not an option. Then I'd probably use an Iframe with javascript.. Quote Link to comment https://forums.phpfreaks.com/topic/138934-solved-filling-forms-sorry-a-bit-vague-i-know/#findComment-726650 Share on other sites More sharing options...
RussellReal Posted December 31, 2008 Share Posted December 31, 2008 <?php // clients.php $page = $_GET['page']; // mysql_connect... ~ fill in your mysql information $q = mysql_query("SELECT * FROM `clients` LIMIT ".(($page - 1) * 20).",20"); while ($f = mysql_fetch_assoc($q)) { echo $f['clientName']."\n"; } ?> <!-- PAGE WHERE CLIENT PAGE LIST SHOULD BE.. --> <script type="text/javascript"> var a; function pushList() { clientList = document.getElementById("clientList"); if (a.readyState == 4) { list = a.responseText.split("\n"); for (i in list) { div = document.createElement("div"); div.appendChild(document.createTextNode(list[i]); clientList.appendChild(div); } } } function pageChange(num) { try { a = new XMLHttpRequest(); } catch (e) { try { a = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { a = new activeXObject("Microsoft.XMLHTTP"); } catch (e) { return null; } } } a.onreadystatechange = pushList; a.open("GET","rawra.php?echo=true",true); a.send(null); } </script> <div id="clientList"></div> <a href="javascript:pageChange(2);">PAge 2</a> <a href="javascript:pageChange(3);">PAge 3</a> <a href="javascript:pageChange(4);">PAge 4</a> please note I wrote this directly into the post box and I havn't tested it.. Quote Link to comment https://forums.phpfreaks.com/topic/138934-solved-filling-forms-sorry-a-bit-vague-i-know/#findComment-726660 Share on other sites More sharing options...
Rohlan Posted December 31, 2008 Author Share Posted December 31, 2008 Thanks again. I can't get it to work, RusselReal. Lots of Javascript errors popup on firefox. I'm not too experienced with javascript so can't really tell what's going on.. Quote Link to comment https://forums.phpfreaks.com/topic/138934-solved-filling-forms-sorry-a-bit-vague-i-know/#findComment-726846 Share on other sites More sharing options...
RussellReal Posted December 31, 2008 Share Posted December 31, 2008 give me a link to the page.. and I'll check it out.. if you have msn add me: RussellonMSN@hotmail.com Quote Link to comment https://forums.phpfreaks.com/topic/138934-solved-filling-forms-sorry-a-bit-vague-i-know/#findComment-726847 Share on other sites More sharing options...
Rohlan Posted December 31, 2008 Author Share Posted December 31, 2008 Thanks to Russel, I've got it working. He pretty much handed me the code and I gladly accepted it and its running perfectly, hurray! Thanks Russel Happy New Year to everyone ~ Quote Link to comment https://forums.phpfreaks.com/topic/138934-solved-filling-forms-sorry-a-bit-vague-i-know/#findComment-726861 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.