canadianjameson
10-22-2005, 09:52 PM
ugly title.
okay. i have a products page here: www.enviromark.ca/english/products.html
on that page i have a list of product manufacturers. when a user runs the mouse over a name of a manufacturer, or clicks it, it shows the products made by that manufacturer.
that is acheived by this little bit of code (for ex: )onmouseover="changetext(content[5]);"
my question this... can i have a link on another page saying
"Click here to view the XYZ company products", and have it not only link to the products page, but also open the "content[5]" onload?
so something like <a href="products.html;content[5]">Click here to view the XYZ company products</a>
is it even possible??
Lerura
10-22-2005, 10:29 PM
You can use a location.search ("?")
<a href="products?valueOFvariable">
if i.e. Content[5] is equal to "T_Shirt"
then then line must be:
<a href="products?T_Shirt">
and on the produts page put:
LS=location.search;
TransferValue=LS.substring(1,LS.length);
then TransferValue will be equal to Content[5]
canadianjameson
10-23-2005, 05:52 PM
You can use a location.search ("?")
<a href="products?valueOFvariable">
if i.e. Content[5] is equal to "T_Shirt"
then then line must be:
<a href="products?T_Shirt">
and on the produts page put:
LS=location.search;
TransferValue=LS.substring(1,LS.length);
then TransferValue will be equal to Content[5]
okay, i like the approach. is this functional in most browsers?
few questions:
Here's a real example: if i had this as my link:
<a href="products.html?content[5]">Click here to view Multifor's products</a>
where on the products page would i put LS=location.search;
TransferValue=LS.substring(1,LS.length)
also, what i'm not seeing is the "TransferValue" usage... because content[5] is the actual part of the array i wish to load when the page loads.
lemme show you with some truncated code from the products page which you can see in action here: www.enviromark.ca/english/products.html
<script>
<!--
var content=new Array()
content[0]='<span>Bindicator</span><br><font size="1">(Celtek Electronics)</font><hr size=1><ul><li><a href="javascript:newWinPDF(\'prodInfo/Bindicator/Phase_Tracker.pdf\');">Phase Tracking</a> continuous level monitoring (Dry and Liquids)</li><li><a href="javascript:newWinPDF(\'prodInfo/Bindicator/loadCell_SpecSheet.pdf\');">Load Cells</a>, yo-yos, etc</ul>'
content[1]='... etc, you get the point'
...
..
.
content[10]...
function regenerate(){
window.location.reload()
}
function regenerate2(){
if (document.layers){
appear()
setTimeout("window.onresize=regenerate",450)
}
}
function changetext(whichcontent){
if (document.getElementsByTagName) {
for(var i = 0;i < fading.length;i++){
clearTimeout(fading[i]);
}
}
if (document.all||document.getElementById){
cross_el=document.getElementById? document.getElementById("descriptions"):document.all.descriptions
cross_el.innerHTML=whichcontent
}
else if (document.layers){
document.d1.document.d2.document.write(whichcontent)
document.d1.document.d2.document.close()
}
initLinkFade();
}
glueHand=changetext;
function nullFunk(){return null};
mousetime=null;
function yarnFace(witchcontent){
changetext=nullFunk;
clearTimeout(mousetime);
glueHand(witchcontent);
mousetime=setTimeout('countDown(5)',0);
}
function countDown(n){
if(!n){
changetext=glueHand;
document.getElementById('countD').style.visibility='hidden'
}
else{
document.getElementById('countD').style.visibility='visible'
document.getElementById('countD').innerHTML=n;
mousetime=setTimeout('countDown('+(n-1)+')',1000);
}
}
function appear(){
document.d1.visibility='show'
}
if (document.layers){
window.onload=regenerate2
}
//-->
</script>
...
</head>
....
<div id="scriptmenu" class="dynamicLinks">
<table cellspacing=0 cellpadding=0 width="70%" align=center border=0>
<tbody>
<tr>
<TD vAlign=top><IMG height=6 alt="" hspace=5
src="images/bull.gif" width=6 vspace=5
border=0></TD>
<TD><span class="link2describe"
onmouseover="status='Bindicator Products';changetext(content[0]);"
onmouseout="status=' '"
onclick="yarnFace(content[0])">Bindicator
</span></TD></TR>
<TR>
<TD colSpan=2>
<HR SIZE=1>
</TD></TR>
</tbody>
</table>
</div>
this is how the script actually works.
so again. where do i place the code on the products.html page and do i need to modify it at all?
felgall
10-23-2005, 09:38 PM
See http://javascript.about.com/library/blqs.htm for an explanation of how to pass variables between pages using Javascript.
Lerura
10-24-2005, 02:19 AM
in that case change the script to:
LS=location.search;
TransferValue=eval(LS.substring(1,LS.length)) and put it
content[1]='... etc, you get the point'
...
..
.
content[10]...
Here
function regenerate(){
window.location.reload()
}
function regenerate2(){
right after the creation of the array.
Then TransferValue will be equal to content[5] in products.html
canadianjameson
10-24-2005, 04:20 AM
lemme try it
k, it didnt open the content[5] :(
heres what i did: on index.html i put <a href="products.html?content[5]">Click here to view Multifor's products</a>
and on the products.html page i put
content[10] ...
LS=location.search;
TransferValue=eval(LS.substring(1,LS.length))
function regenerate(){
window.location.reload()
...
i put up mock links so you could see and maybe get a better feel.
www.enviromark.ca/english/indexTest.html --> bottom of page(ish) "Click here .. Multifor"
www.enviromark.ca/english/productsTest.html
Lerura
10-24-2005, 04:58 PM
you have created the function changetext()
this function can be used for the issue.
replace
LS=location.search;
TransferValue=eval(LS.substring(1,LS.length))
with
function onLoadChangetext(){
if (location.search){
LS=location.search;
TransferValue=eval(LS.substring(1,LS.length))
changetext(TransferValue);
}}
and add onLoad="onLoadChangetext();" to your bodytag
canadianjameson
10-25-2005, 03:44 AM
BOOYA!
perfect!!
thats EXACTLY what i wanted!