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

QueryString 1

Status
Not open for further replies.

arpan

Programmer
Oct 16, 2002
336
IN
An HTML Form has a drop-down select list in which any option selected by the user will fire a JavaScript onChange event thereby changing the querystring of the URL. The querystring already has the user's loginid as one name-value pair. For eg. if a user has selected say, apple, from the drop-down menu, then fruit=apple will get APPENDED to the querystring (provided the user has selected an option for the 1st time). Next if he select mango, the querystring will CHANGE to fruit=mango. Please note that when a user selects an option, the onChange event gets triggered & the page comes back to itself (just the querystring in the URL changes). This Form also has a textbox where users can enter dates (in dd-mm-yyyy format). A default date is also specified for this texbox. Now this is what I am doing in the onChange event (suppose this file is named Fruit.asp):

<%
Dim strLoginID,strFruit
strLoginID=Request.QueryString(&quot;loginid&quot;)
strFruit=Request.QueryString(&quot;fruit&quot;)
%>
<script language=&quot;JavaScript&quot;>
function gotoURL(obj){
var str1=document.scope.fruit.value;
window.location.href=obj.options[obj.selectedIndex].value;
}
</script>
<body>
<form name=&quot;scope&quot; action=&quot;SomePage.asp&quot;>
<input type=text name=&quot;putdate&quot; value=&quot;31/1/2002&quot;>
<select name=&quot;fruit&quot; onChange=&quot;gotoURL(this.form.fruit)&quot;>
<option value=&quot;Fruit.asp?loginid=<%= strLoginID %>&fruit=mango&quot;>Mango</option>
<option value=&quot;Fruit.asp?loginid=<%= strLoginID %>&fruit=apple&quot;>Apple</option>
<option value=&quot;Fruit.asp?loginid=<%= strLoginID %>&fruit=banana&quot;>Banana</option>
</select>
</form>

Now, as expected, when a user selects a fruit, the querystring changes accordingly. What I want is is there someway, maybe by using JavaScript (or even ASP will do!!), the date entered by the user (or the default date already specified) can also be passed to the querystring when an option is selected by a user from the drop-down menu?

Thanks,

Arpan
 
<%
Dim strLoginID,strFruit
strLoginID=Request.QueryString(&quot;loginid&quot;)
strFruit=Request.QueryString(&quot;fruit&quot;)
strDate=server.Request.QueryString(&quot;putDate&quot;)
if not isDate(strDate) then strDate = &quot;31/1/2002&quot;
%>
<script language=&quot;JavaScript&quot;>
function gotoURL(obj){
var str1=document.scope.fruit.value;
window.location.href=obj.options[obj.selectedIndex].value + &quot;&putDate=&quot; + server.urlEncode(document.scope.putdate.value);
}
</script>
<body>
<form name=&quot;scope&quot; action=&quot;SomePage.asp&quot;>
<input type=text name=&quot;putdate&quot; value=&quot;<%=strDate%>&quot;>
<select name=&quot;fruit&quot; onChange=&quot;gotoURL(this.form.fruit)&quot;>
<option value=&quot;Fruit.asp?loginid=<%= strLoginID %>&fruit=mango&quot;>Mango</option>
<option value=&quot;Fruit.asp?loginid=<%= strLoginID %>&fruit=apple&quot;>Apple</option>
<option value=&quot;Fruit.asp?loginid=<%= strLoginID %>&fruit=banana&quot;>Banana</option>
</select>
</form>
-- Just trying to help...
[wolf]<--- This is a wolf? We need a new icon.......
mikewolf@tst-us.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top