Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple SELECTS with the same data

Status
Not open for further replies.

foxbox

Programmer
Sep 11, 2000
1,052
NL
I have a form with 5 different fields that require the user to enter a valid name-code. [The valid codes are stored in a SQL database (about 150)].
I do not want to build 5 <SELECT>'s with 5x150 <OPTION> lists.
Of course it is possible to enter 5 codes first, and do the validation after pressing SUBMIT, but this is less-user friendly.
So i suppose i look for something that is checking the entered code whenever the user is leaving the field. If the code is wrong, a list is presented....
I also like to have the check client-side.
br
Gerard
(-:

Better a known bug then a new release.
 
You could build up a client side javascript array at 150 elements and run a check on it onBlur each time a user leaves a certain box --

Here's a FAQ on how to make the array: faq329-603 -- by reading server variables into the client side array --

and then it would just be a simple function that would use a for loop and one boolean value that would flick on when the value was found, or stay off if it wasn't found -- then you could either alert the user that the value was not valid, or do nothing if the value is valid.

if this wasn't clear, then let me know, and I'll work up a sample function.

:)
Paul Prewett
 
Oke, I'm now working on this idea:

<form name=frm1>
<select name=fName onfocus=&quot;fillselects();&quot;></select>
</form>


<script language=JavaScript>
function fillselects(){
for (var i = 0; i < 10; i++){
document.frm1.fName.options[document.frm1.fName.options.length]=
new Option(&quot;display string &quot; + i, &quot;value &quot; + i);
}
}
</script>


. . . so i fill the SELECT dynamically . . .
br
Gerard
(-:

Better a known bug then a new release.
 
Yea, I think I see what you're getting at. I do that for my intranet here for taking out a new project number -- it's all <select> driven so that I enforce the business rules of the data and give the user no choice but to enter valid data -- but I build them like this:

<%
response.write(&quot;<select name=pm>&quot;)
response.write(&quot;<option value=none>SELECT ONE</option>&quot;)
while not rs.eof
response.write(&quot;<option value=&quot; & rs(&quot;empID&quot;) & &quot;>&quot;)
response.write(rs(&quot;lName&quot;) & &quot;, &quot; & rs(&quot;fName&quot;))
response.write(&quot;</option>&quot;)
rs.movenext
wend
response.write(&quot;</select>&quot;)
%>

so that for each select, I have a recordset in memory that holds valid data, and just go through and build them up like that, instead of writing it with javascript. and they are all built up when the page finishes loading, rather than onFocus.

In your example, I guess you are filling it from the array that you built from the recordset when the page loaded? I think this way may be easier on resources...

:)
 
In your example, I guess you are filling it from the array that you built from the recordset when the page loaded? I think this way may be easier on resources...


Yep, but i like to test small, and expand a something that works (ceteris paribus) ;-) br
Gerard
(-:

Better a known bug then a new release.
 
foxbox, this is un-related but it sounds like you might be able to help me. Here's my gig:

I've used Access look-up (Lookup Wizard) when creating a table before in order to display information from another table. How do you do this sort of thing with SQL? Just point me in the right direction (tutorial, online articles, etc.), I'm not looking for any handouts. I want to learn and understnad how this works.

I'm using Visual InterDev to build ASP pages to work with a with a SQL backend. I want our IT team to be able to use web pages (ASP pages) to add, edit, delete, and search for records in the SQL database. I'm using it for inventory tracking, among other things. Here's one thing I'm trying to accomplish:

I made a table to hold user name, amount of RAM, serial number, manufacturer, model, and many other fields for our desktop computers. When someone opens this table (or data entry page) to add a new record, I'd like to make the manufacturer field to &quot;lookup&quot; records from another table I made called &quot;desktop_manufacturers.&quot; I'm trying to minimize the amount of manual data entry our team will do. Therefore I've made several tables to hold information that will be used in other tables, or maybe queries. Am I using the wrong terminology? I'm tired of running into useless descriptions in Microsoft's documentation. Can you help get me started on this?
Thanks,
David
 
David,
From your description, sounds like what you're asking about is table joins. Since you are using Access (and if you're pretty familiar with it which I'm not) you can select the tables you want to look at and link them however you like, build your query then you can click on &quot;View SQL&quot;. It may not be exactly correct but will give you a real good start on how to build your SQL statement.
hth
mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top