Jump to content

[SOLVED] Filling forms (sorry, a bit vague, I know)


Recommended Posts

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  8)

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.

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..

<?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..

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.