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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Forms/DropDowns/AddingRecords HELP!!!

Status
Not open for further replies.

rossmcl

Programmer
Apr 18, 2000
128
0
0
A form with dropdowns (souced from a database tables/ queries) each dropdown dependant on the dropdown above it.<br>Then a button to post the result onto a Access table and email the administrator<br><br>THATS WHAT I WANT!!!<br><br>Anyone got the source for that?<br><br>I will kiss your feet if you do!<br><br>Ross McLanachan
 
Dear Ross,<br><br>It's not likely that someone will have the source for 'that' exactly. What it sounds like your asking for is someone to write your application for you. I won't do that but I will break it up for you and suggest approaches. Then if you need help with specific coding later I will also help with that.<br><br>* Loading combo boxes from database sources - This is fairly simple assuming you already know how to work with ADO in ASP. For each item in the drop down list you need 1) display text 2) item value. Then you use the rows from your query to build the &lt;option&gt; tags.<br><br>* Each drop down dependant on the one above it - Not quite so simple, a clarification of 'dependant on' would help here. Two different techniques can be applied here. 1) client side script to change the selected item in the dependant drop down when the active drop down is changed. 2) server side script to modify the contents of the dependant drop down when the active drop down is changed.<br><br>With number (2) keep in mind that round tripping to the server is not usually a great solution. If you are in an intranet environment you might be able to get away with it.<br><br>* Update the database - Again this is fairly simple if you know how to work with SQL and ADO in ASP. This simplest technique is to generate 'insert' and 'update' statements with the Request(&quot;&quot;) parameters injected into the right places.<br><br>* Email the adminstrator - This is real simple if you have the CDONTS set installed and the SMPT server working. You can find sample code for using the email control at www. msdn.microsoft.com and use the search string &quot;CDONTS.Email&quot;.<br><br>Hope this helps<br>-pete<br>
 
Pete.<br>I think you misunderstood.<br>I have got as far as getting the data from Access2000 into the first listbox.<br>The problem I am having is:<br><br>How do I take the value from that listbox into a query which another listbox below is based on. That is my real question. I was wanting to see the code so I could see how this is done, where a value from a listbox is used in the query for another listbox on the same page. Any direction you can give me on this would be much appreciated.<br><br>As an aside, I am in an Intranet setup.<br><br>THanks<br>Ross<br>
 
Dear Ross,<br><br>Ok, so you are going back to the server after the user selects an item from a drop down to load the values in the next drop down.<br><br>First drop down:<br>&lt;select name=&quot;division&quot;&gt;<br>&nbsp;&nbsp;&lt;option value=&quot;201&quot;&gt;Western&lt;/option&gt;<br>&nbsp;&nbsp;&lt;option value=&quot;300&quot;&gt;Central&lt;/option&gt;<br>&nbsp;&nbsp;&lt;option value=&quot;350&quot;&gt;Eastern&lt;/option&gt;<br>&lt;/select&gt;<br><br>When the user selects 'Central' and you submit the form the request variable named 'division' in your asp code will contain the value '300'. Then you use that to build your SQL statement to retrieve the rows for the next drop down.<br><br>&lt;% var sql = &quot;select * from agents where agents.divisionID = &quot; + Request(&quot;division&quot;);<br>&nbsp;&nbsp;rs.Open( sql, ......);<br><br>%&gt;<br>... now build the select tags etc.<br><br>Are we on the right track yet?<br><br>-pete
 
I think Ross wants to do this without submitting. It's possible, but will draw big time on your server, and your database. Not highly recommended, however, it might be possible to make it look like it's on the same page. <br><br>I guess before going anywhere, there are a few questions Ross needs to answer:<br><br>1. Are you familiar enough with asp code to get this indepth? (Why? Because it gets quite complex here, lots of people could give you the general logic, but I doubt you will find code unless someone is bored one night and tries it just to see if they can.)<br><br>2. Does your company have a specific browser it supports? (Why? Because some solutions might be browser specific. You can use DHTML with ASP to create the effect you want.)<br><br>3. How often does the database change? At least the part of the database that is populating your drop downs. Also, what data is updating the database? And is it updating the same tables or different tables?<br><br>I guess, if I get bored, this might be a challange I'd take on, but I need more info.<br><br>Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top