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

Reload page and populate two fields from QueryString

Status
Not open for further replies.

jofarrell

Programmer
Joined
Mar 21, 2001
Messages
178
Location
US
I have a JavaScript that reloads the form after two dates are entered and I store them in the url, is there a way to have these dates either remain in their respective textboxes, or a way to fill them on load of the form? I need this to occur because if information is entered in these fields then data previously stored in the database will be shown.

Any suggestions?

Thank you

Joanne
 
You can use my querystring object to retrive the values, but they have to be in "proper" querystring format (you may also have to escape them, but I doubt it):

<a href=&quot;mypage.htm?date1=10/10/2001&date2=10/10/2001&quot;>

then:

function QSHandler()
{
var i,j,tmparray,strata,prlen
strata = window.location.search
strata = strata.substring(1,strata.length)
if(strata.indexOf('&')>=0)
{
prsarray = strata.split('&')
prlen = prsarray.length
tmparray = new Array()
for(t=j=0;j<prlen;j++)
{
tmparray[t++] = prsarray[j].split('=')[0]
tmparray[t++] = prsarray[j].split('=')[1]
}
}
else
{
tmparray = new Array(strata.split('=')[0],strata.split('=')[1])
}
tlen = tmparray.length
this.data = new Array()
for(i=0;i<tlen;i++)
{
this.data[new String(tmparray)]=tmparray[++i]
}
this.QueryString=function(x)
{
return this.data[x]
}
}
Request = new QSHandler()

and reference the dates like so:

date1 = Request.QueryString(&quot;date1&quot;)
date2 = Request.QueryString(&quot;date2&quot;) jared@eae.net -
 
Thank you very much for your idea, I managed to directly assign the values to the textboxes using an if then statement if there is data present in the query string.

Once again thanks for rsponding.

Joanne
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top