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

Requery a recordet using a javascript function

Status
Not open for further replies.

Pete78

Programmer
Aug 21, 2003
10
0
0
GB
Hi,

I want to be able to populate some text boxes on a form based on what the user enters in another text box. The automatically populated text boxes should be populated from a recordset which is created using the value entered by the user. I have created the recordset based on the value of a particular text box. The problem is this Recordset is generated when the page loads and I want to requery the recordset once the user has entered a value in the specific text box. I can then populate the other textboxes with the requeried recordset. Is this possible???? (To give you more of an idea, I basically want to create a quick address facility on my page allowing the user to enter their post/zip code and the rest of the address fields to be automatically populated.
 
1. Pag1.asp - make a form and submit it to action page (Page2.asp) where u filter the record set by Request.(ing)Form("tfZIP")

2. Page.asp - make a recordset & a form, ones the record is found in the set then set the form's fields default values to hold the found record...
eg.
<input type=&quot;text&quot; name=&quot;tfAddress&quot; size=&quot;40&quot; value=&quot;<%=(RS.Fields.Item(&quot;Address&quot;).Value)%>&quot;>


All the best!

> need more info?
:: don't click HERE ::
 
Thanks Lebisol,

The problem I now have is that some of the other fields in my form may have already been populated by the user. I have managed to get all the text boxes in the second form to be populated with data entered in the equivalent controls (Text Boxes) in the first form. However I cant get the select boxes (combo boxes) to do the same.

Any Advice?
 
then we need to use IF statements to ensure than the fields on Page1.asp were empty/populated.
So on your Page2.asp u would &quot;conditionally&quot; polute your form fields.
eg.
Page2.asp--------------------

IF (Request.Form(&quot;tfAddress&quot;) <> &quot;&quot;) THEN
varAddress = Request.Form(&quot;tfAddress&quot;)
input type=&quot;text&quot; name=&quot;tfAddress&quot; size=&quot;40&quot; value=&quot;<%= varAddress %>&quot;>

>>'if it was populated by user then make a variable of that entry add use its entered value



ELSE
varAddress = Request.Form(&quot;tfAddress&quot;)
input type=&quot;text&quot; name=&quot;tfAddress&quot; size=&quot;40&quot; value=&quot;<%=(RS.Fields.Item(&quot;Address&quot;).Value)%>&quot;>

>> if it WAS emptry - nothing entered then use the value from the DB
------------------------


All the best!

> need more info?
:: don't click HERE ::
 
This is excellent you're really helping. Now I have one more question. As I explained the reason for wanting to do this was to enable a quick address. The problem is that I want the user to be able to submit the form to the database staight away if they select the submit button and get a quick address (open page2.asp and populate the controls) if they select the Quick Address button. Because the form is set up to open page2.asp both buttons do the same thing. Is there a way I can have one button to submit the form to the database and one button to submit the form to page2.asp???

Thanks for all your help!
 
I have another little problem that i'm sure you would be able to help me with.

I want to write a javascript function that will take the value of a select box and put it into a text box. I'm just not sure how to get and set the values of the controls.(Is there another way of doing this by binding the two controls together or something)?

Thanks
 
LOL one question at the time.....
&quot;The problem is that I want the user to be able to submit the form to the database staight away if they select the submit button and get a quick address &quot;
--what quick address?from the DB? the one that they just typed in?


&quot;one button to submit the form to the database and one button to submit the form to page2.asp???&quot;
--u can not &quot;submit a form to the DB&quot;...u can INSERT,UPDATE etc data from the forms....is this what u meant?
u can use Page1.asp with a form and submit it to Page2.asp if u use appropriate command (to update,del.,etc.) while u can have the other button submit the form to the PageX.asp which will NOT do any DB insertion....

I belive I gave user &quot;mother&quot; a sample out here...in MM forums...I can't remember the thread name right now....try searching
All the best!

> need more info?
:: don't click HERE ::
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top