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

How do I get Query string data to display in a text box? 1

Status
Not open for further replies.

jofarrell

Programmer
Mar 21, 2001
178
US
I wish to reload a page and on doing so I save the variables that they entered (two dates) add the as a query portion of a url. I then request.querystring to get the data but I am unclear how I can add the info to the corresponding textboxes. Any suggestions?? Here is what I am using in VBScript


d1 = Request.QueryString("Date1")
if d1 <> &quot;&quot; then
form.Date1.value = d1
else
Date1 = Request.Form(&quot;Date1&quot;)
end if

Thanks for any help offered :)

Joanne
 
looks like you're mixing server and client side scripts there...

request.querystring is a server method

assigning values to a form element is the client's &quot;job&quot;, and as such, the form object(s) are not available to the server side code...

<%
d1 = Request.QueryString(&quot;Date1&quot;)
%>

gets the value into your variable. You can then assign it directly to the text box by saying:

<input type=text name=d1 value=&quot;<%=d1%>&quot;>

Or programatically by putting in some javascript:

<script language=javascript>
document.formName.d1.value = '<%=d1%>';
</script>

would be the inline solution, or you could easily abstract it into a function and then call the function in your onLoad event for the body of your document.

Of the two, probably the direct assignment is the quickest and easiest.

hope that helps! :)
Paul Prewett
penny.gif
penny.gif
 
I did actually have my <% %> tags around that stuff above but in my haste to explain I forgot someone may see that as a big no no *grin*

this was above the header, there is a javascript code that seems to reload the page as I wish it to ... so in the <form> section I should place the direct method of adding these values ... and yes I am new to ASP so sometimes my ordering is a bit off ... I am a VB coder dabbling in the web realm cause they are making me, so forgive me if I ask stupid questions :)

Joanne
 
Is there such a thing as a stupid question? ;-)

Yes, just use that direct method of assignment (don't forget the quotes if there is going to be a space in there, or you'll lose everything after the first space) once you have the desired values in your server side variable, and you'll be good to go.

:)
penny.gif
penny.gif
 
*hops*

Thank you .. that worked wonderfully .... its amazing what amuses me after weeks of frustration *grin* Just think of a big hug of thanks coming your way :)


Joanne
 
Don't forget to post here with all your questions... it will save you those weeks of frustration. Plenty of good advice to go around from all the members of this site.

:p
penny.gif
penny.gif
 
You are so right in that there is plenty of good advice and suggestions here. Thank you for taking the time to share that with me :)

Joanne
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top