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

Retrieving a QueryString

Status
Not open for further replies.

johnsimpson

Programmer
Mar 28, 2006
60
GB
Hi guys, need a little help.

Basically i have a HTML list menu (drop down list) and on selection the user will be directed to a specific page.

In this link i am including a querystring ?state=New York

When the user is taken to the appropriate page i am retrieving the querystring and using it as a title for the page. The problem is its displaying as New%20York. So its replacing the space with %20.

How can i remove this from the querystring? so it displays properly?

thanks
John
 
Dan, this works perfectly, thanks very much, you saved me a lot of time!!
 
next question, is how can i preselect the appropriate list item by sending a querystring?

So i want to select for example Manchester from a dropdown list, this will then redirect to contact.html?=New%20York and i want it to select the option New york from the drop down list menu on the target page

thanks

J
 
That depends on many things.

Personally, I'd do all this server-side, as doing it client-side will mean people with no JavaScript enabled will not be able to use your site.

Dan



[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Try adding this line to your function that's putting "New York" into the page's title:

Code:
document.forms['form_name'].selects['select_name'].selectedindex = 'New York';

...if that doesn't work, post your code (JavaScript you're parsing the URL with, and HTML for the form) here & maybe one of us will catch the error.




I hope this helps;
Rob Hercules
 
Thank you for pointing that out Dan;

I think this script will do it though:

Code:
var num = 0;
var Found_iT = false;
var FoO = document.forms['form_name'].selects['select_name'];
while((num < FoO.options.length) && (!Found_iT))
{
 if(FoO.options[num].value == 'New York')
 {
  FoO.selectedIndex = num;
  Found_iT = true;
 };
 num++
};




I hope this helps;
Rob Hercules
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top