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

QueryString's

Status
Not open for further replies.

puremm

Technical User
Oct 30, 2006
23
0
0
GB
I wonder if anyone can assist me with an issue I'm having?
I'm sort of new to the world of javascript, I have a page that pulls a list of records in asp, and I'm trying to past the varibles, and have them display a gallery of images.

Now I have no problem getting the QueryString passed onto the second page, and also have a piece of javascript read the QueryString, what I can't seem to do, is get onLoad to read the QueryString. Please find the code listed below;

<script type="text/JavaScript">
var Suffix
var Images
Suffix = "<%=Request.QueryString("Suffix")%>";
Images = "<%=Request.QueryString("Images")%>";

onLoad = "gallery('Suffix', 'Images');"
</script>

Can anyone point me in the right direction...
 
Where's the code for gallery()? What does the query string look like when this page loads?

Lee
 
the QueryString looks like;


As for the code for the gallery(); please find this listed below;

function gallery(picset, number)
{
var picsethtml=new Array()

picsethtml[0] = "<ul>";

for (i=1;i<=number;i++)
{
if (i/3 % 1 == 0){
picsethtml = '<li><a href="fullplate.asp?image='+picset+i+'" target="_blank" ><img src="../upload/gallery/'+picset+i+'.jpg" width="200" height="140" alt="click the thumbnail to enlarge"></a></li>';
}
else
{
picsethtml = '<li><a href="fullplate.asp?image='+picset+i+'" target="_blank" ><img src="../upload/gallery/'+picset+i+'.jpg" width="200" height="140" alt="click the thumbnail to enlarge"></a></li>';
}
}
picsethtml[number+1] = "</ul>";

document.getElementById('gallery').innerHTML = picsethtml.join("");
}

Thanks you for the prompt reply.
 
First, you have an extra semicolon in your query string, which will probably interfere with finding the Images variable.

You pass the character strings 'Images' and 'Suffix' to the gallery() function, but not the variables themselves.

I would also change
Code:
if (i/3 % 1 == 0)
to
Code:
if (i % 3 == 0)
to avoid potential floating point errors. Modulo arithmetic works with integers only, I believe, and not floating points.

However, there doesn't seem to be any difference in your code in the if and else statements, so I'm not sure why you have that conditional to begin with.

Lee
 
Thanks, sort of get what your saying. Then how do I pass the variables, rather than the characters strings???

As for the difference in the IF and Else statements, that should contain a reference to a blank image preset.

 
You're asking some real basic questions, so I'd recommend you do a Google search for Javascript tutorials.

And always copy and paste your code in here from the original so we can see exactly what the browser is working with.

Lee
 
>onLoad = "gallery('Suffix', 'Images');"
What do you mean by that? Maybe this?
[tt]onLoad = function() {gallery('<%=Request.QueryString("Suffix")%>';,'<%=Request.QueryString("Images")%>');}
[/tt]
 
tsuji, thanks that got me halfway there...

But now I'm getting an unknown error on line 20 of the function listed above...
 
the client-side output is as follows;


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<html xmlns="<head>
<title>Elite Teens 13-17 :: Elite Teens Photo Gallery</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="../css/elitestyle.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" language="JavaScript" src="../scripts/gallery.js" ></script>
<script type="text/JavaScript">
<!--
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a)&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//-->
</script>
</head>
<body onLoad="gallery('30092006_','21');">

<div id="layout">

<div id="header">
<div id="navi">
<table cellpadding="0" cellspacing="0" class="table">
<tr>
<td width="69" height="38"><a href="../default.asp"><img src="../assets/home.png" alt="Home" name="home" width="69" height="38" border="0" id="home" onmouseover="MM_swapImage('home','','../assets/home_a.png',1)" onmouseout="MM_swapImgRestore()" /></a></td>
<td width="68" height="38"><a href="info.asp"><img src="../assets/news.png" alt="Information" name="news" width="68" height="38" border="0" id="news" onmouseover="MM_swapImage('news','','../assets/news_a.png',1)" onmouseout="MM_swapImgRestore()" /></a></td>
<td width="100" height="38"><a href="gallery.asp"><img src="../assets/gallery.png" alt="Photo Gallery" name="gallery" width="100" height="38" border="0" id="gallery" onmouseover="MM_swapImage('gallery','','../assets/gallery_a.png',1)" onmouseout="MM_swapImgRestore()" /></a></td>
<td width="88" height="38"><a href="events.asp"><img src="../assets/events.png" alt="Events" name="events" width="88" height="38" border="0" id="events" onmouseover="MM_swapImage('events','','../assets/events_a.png',1)" onmouseout="MM_swapImgRestore()" /></a></td>
<td rowspan="2"><a href="/users/download.asp"><img src="../assets/download.png" alt="Downloads" name="downloads" width="78" height="78" border="0" id="downloads" /></a></td>
</tr>
<tr><td colspan="4">
<table cellpadding="0" cellspacing="0">
<tr>
<td><a href="board/default.asp"><img src="../assets/messages.png" alt="message board" name="messages" width="133" height="40" border="0" id="messages" onmouseover="MM_swapImage('messages','','../assets/messages_a.png',1)" onmouseout="MM_swapImgRestore()" /></a></td>
<td><a href="shop.asp"><img src="../assets/info.png" alt="Elite Teens Shop" name="info" width="70" height="40" border="0" id="info" onmouseover="MM_swapImage('info','','../assets/info_a.png',1)" onmouseout="MM_swapImgRestore()" /></a></td>
<td><a href="contact.asp"><img src="../assets/contact.png" alt="Contact Us" name="contact" border="0" id="contact" onmouseover="MM_swapImage('contact','','../assets/contact_a.png',1)" onmouseout="MM_swapImgRestore()" /></a></td>
</tr>
</table>
</td></tr>
</table>
</div>
</div>

<div id="content">

<div id="main_right">

<div class="heading"><img src="../assets/header02.png" alt="welcome heading" width="300" height="40" /></div>

<div id="gallery" class="gallery"></div>

<div class="disclaimer"><img src="../assets/disclaimer.png" width="96" height="16" align="absmiddle" />
Eliteteens cannot be held responsible for the content of the messageboards or the content found on external websites.
The views expressed on Eliteteens meesageboard are not the views or opinions of any Eliteteens staff members, at the events or otherwise.
</div>

</div>

<div id="main_left">

<div class="tickets">
<a href="register01a.asp"><img src="../assets/ticket_ad.png" alt="Click Here to join Elite Teens" width="109" height="116" border="0" /></a> </div>

<div class="events">
<table width="150px" height="110px" border="0" align="center" cellpadding="0" cellspacing="0">
<tr><td width="150px" valign="top" >
<marquee width="150px" height="110px" onMouseOver="this.stop()" onMouseOut="this.start()" direction="up" scrollamount="1" style="Filter:Alpha(Opacity=100);">
<table width="150px" border="0" align="center" cellpadding="0" cellspacing="0">
<tr><tr><td>
<h3>The 'Giveaway' Nite</h3>
<h4>21st October 2006</h4>
<p>Expect masses of CDS, T-Shirts & Party Stuff on the nite @ Latin Quarter, Conway St, Birkenhead.</p>
</td></tr>
</table>
</marquee>
</td></tr>
</table>
</div>

<div class="login">
<form action="../ " name="LogonForm" method="POST">
<div align="center">
<input name="Username" type="text" style="width:140px" value="Username" />
<input name="Password" type="text" style="width:140px" value="Password" />
</div>
<div class="remember"><input name="RememberMe" type="checkbox" checked="checked" />Remember my details...</div>
<div class="buttons">
<div align="right"><a href="#" onclick="LogonForm.submit();"><img src="../assets/login.png" alt="Logon Member" width="66" height="29" border="0" align="absmiddle"></a> </div>
</div>
</form>
</div>
</div>
</div>

<div id="footer">
<p><a href=" and <a href=" </p>
</div>

</div>

</body>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top