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!

Query or param passing with Javascript

Status
Not open for further replies.

Kaele7

Programmer
Dec 5, 2008
6
US
Hello, I've got a bit of a problem and have been searching for hours for a solution. Basically I have a unique layout for a blog section of my website that is purely XML/XSL. I have a for-each loop that prints out all the blog entries from an external xml file, what I'm trying to do is make a comments link that will display only the current post as well as a comment box.

My main problem is that I want the page to be able to update itself automatically when I put in a new entry into the external xml file without having to go in and recode.

My first thought was to pass a string query and let javascript do all the work but that isn't very stable. I'm just trying to figure out how to change a param node parent element with javascript through an onclick function. Any help would be greatly appreciated. Here are the appropriate pages:

 
So far what I've got are a few <xsl:if> statements dividing up the sections on the page. What I'm still trying to figure out is how to pass a query string from a javascript variable into a form that the xsl can recognize. Two options are passing a paramater, or changing an xml node. I've tried the latter but it's only a temporary change that is only applied locally in a javascript variable.

var URL1 = unescape(location.href) // get current URL in plain ASCII
var xstart1 = URL1.lastIndexOf("?") + 1
var xend1 = URL1.length
var current_page;

if (URL1.lastIndexOf("?") != 0) {
current_page = URL1.substring(xstart1,xend1);
} else {
current_page = "&#160;"
}
document.write(current_page);
var xmlDoc=loadXMLDoc("/strings/comment_page.xml");

var x = xmlDoc.getElementsByTagName("value")[0].childNodes[0];
x.nodeValue = current_page;
var txt = x.nodeValue;


There has to be another option besides putting my entire page in a xml processor script. Any ideas?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top