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!

including javascript variable value in xml string

Status
Not open for further replies.

iamdavidlee

Programmer
Nov 18, 2003
15
GB
Hi

I have a html pages which has some querystring vales...


I am now trying to get the querysting using javascript and pass it to an XML parser but i dont know how to do that.

The XML parser should look like this...
<xml id="cdcat" src="
But I am not sure how to add the querystring value in the in the above line.

I teid the following
<script language="javascript">
fullURL = parent.document.URL
xxx = fullURL.substring(fullURL.indexOf('?')+3, fullURL.length)
alert(xxx);
</script>

<xml id="cdcat" src="
But this didnt work... help please.....

would really appreciate the help...

Thanks
David
 
To get the query string, you would do this:

Code:
var qStr = location.href.substr(location.href.indexOf('?')));

then to append it to the src parameter, you can use this:

Code:
<xml id="cdcat" src=""></xml>

with this:

Code:
document.getElementById('cdcat').src = '[URL unfurl="true"]http://www.example.com/test.asp'[/URL] + qStr;

Hope this helps,
Dan

[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]
 
thank you for the reply... i will try it out, if it doesnt work i will try and use PHP...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top