View Full Version : is it possible to transfer a parameter in image_template.html?
jdleung
07-10-2006, 05:43 PM
for example, there is a link with anchor like this:
index.php?aaa=1#
another link in the same page:
index.php?x=comment&my_para=aaa
how can I transfer the value of aaa to my_para?
not in php, but html
javascripts? or else?
jdleung
07-10-2006, 10:54 PM
how? GeoS,
I.e. by parsing content of whole page or just getting to the link by DOM, using i.e. XPath or without it. There is many ways for it.
jdleung
07-10-2006, 11:53 PM
DOM,Xpath. I have never heard about it!
you may give a sample.
thanks.
I.e. in my small lib supporting data preparation for AJAX you have (I sent it to you):
document.getElementById("parent_name")...
Where 3 dots it some method to get one of attributes from tag.
Then you must process it and get query string and at the end get only selected variable.
But elements of site must have own unique ID attribut.
Please look in the web (i.e. google) :)
jdleung
07-11-2006, 06:23 AM
GeoS,
can you explain clearer? or it's better to give me a sample.
I'm a stranger in ajax. :-(
i.e. such links:
http://www.google.com/search?q=how+to+get+getelementbyid+JavaScript&btnG=Search
http://www.thescripts.com/forum/thread91974.html
http://www.quirksmode.org/dom/ (very good one)
http://www.java2s.com/Code/JavaScript/Development/GetaspecifiedelementusinggetElementById.htm
and mixing with other stuff you will get what you want.
jdleung
07-13-2006, 03:54 AM
I think this is the simple and the best one
<html>
<head>
<script type="text/javascript">
function getElement(){
var x=document.getElementById("myHeader")
alert("I am a " + x.tagName + " element")
}
</script>
</head>
<body>
<h1 id="myHeader" onclick="getElement()">Click to see what element I am!</h1>
</body>
</html>
I want to how to get the " + x.tagName + " into my link?
index.php?x=comment&my_para= x.tagName ????
jdleung
07-13-2006, 03:56 AM
GeoS,
I'll tell you my odd thinking if this is ok. I'm testing.
<html>
<head>
<script type="text/javascript">
function getElement(){
var x=document.getElementById("myHeader")
var link = 'index.php?x=comment&my_para=' + x.tagName;
alert("I am a " + x.tagName + " element")
}
</script>
</head>
<body>
<h1 id="myHeader" onclick="getElement()">Click to see what element I am!</h1>
</body>
</html>
Read the rest of links. There are a lot of examples also to harder to implement stuff.
<script>
function getQueryVariable(variable) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if (pair[0] == variable) {
return pair[1];
}
}
alert('Query Variable ' + variable + ' not found');
}
</script>
Now make a request to page.html?x=Hello
<script>
alert( getQueryVariable("x") );
</script>
jdleung
07-13-2006, 09:50 AM
Geos, no need now.
I'm going to use it on the comment page, and I think yours is the best ;-)
waiting...
vBulletin® v3.7.3, Copyright ©2000-2013, Jelsoft Enterprises Ltd.