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

Asp request javascript onclick 1

Status
Not open for further replies.

ro6er

Programmer
Jul 1, 2003
76
0
0
I'm trying to request an onclick link on a page:

Code:
<a class="opacityit" href="#" onclick="javascript:showDiv();picx='<%=rs("ID")%>'"><img border="0" src="productimages/<%=rs("Thumbs")%>" width="79" height="79" alt="<%=rs("Alt")%>" /></a>
How would I request this in asp? I can't seem to get this to work.

Code:
Response.Write request("picx")
doesn't seem to work. I know it has to be something simple..
 
? Move the rs("id") inside de showDiv() brackets, because i presume that function is accepting 1 parameter ?

<a href="#" onclick="javascript:showDiv(<%= rs("ID") %>)">
Picture</a>


request.querystring("id") will give you the id that was given to the script as a parameter (page1.asp?id=1)

request.form("id") will give you the id from a POSTed previous page

rs("picx") is a reference to a recordset field




 
Hi,

thanks that seems along the right lines but I still can't get it to work. Here's my full code
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/strict.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml"[/URL] xml:lang="en" lang="en">
<head>
<title>Funkfabriek</title>
<LINK REL="SHORTCUT ICON" HREF="TinyFF.ico">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />


<style type="text/css">
@import "scripts/main.css";
@import "scripts/scroll.css";
</style>

<!--#include file="menuchange.asp"-->
<script language=javascript type='text/javascript'> 
//function function1(){
//document.getElementById('hideshow').style.visibility = 'hidden'; 
//} 
function hideDiv() { 
if (document.getElementById) { // DOM3 = IE5, NS6 
document.getElementById('hideshow').style.visibility = 'hidden'; 
} 
else { 
if (document.layers) { // Netscape 4 
document.hideshow.visibility = 'hidden'; 
} 
else { // IE 4 
document.all.hideshow.style.visibility = 'hidden'; 
} 
} 
}
 
function showDiv() { 
if (document.getElementById) { // DOM3 = IE5, NS6 
document.getElementById('hideshow').style.visibility = 'visible'; 
} 
else { 
if (document.layers) { // Netscape 4 
document.hideshow.visibility = 'visible'; 
} 
else { // IE 4 
document.all.hideshow.style.visibility = 'visible'; 
} 
} 
} 
</script> 
<script src="scripts/dw_scrollObj.js" type="text/javascript"></script>
<script src="scripts/dw_glidescroll.js" type="text/javascript"></script>
<script type="text/javascript">

<!--
/*************************************************************************
  This code is from Dynamic Web Coding at [URL unfurl="true"]www.dyn-web.com[/URL]
  Copyright 2001-4 by Sharon Paine
  See Terms of Use at [URL unfurl="true"]www.dyn-web.com/bus/terms.html[/URL]
  regarding conditions under which you may use this code.
  This notice must be retained in the code as is!
*************************************************************************/

function initScrollLayer() {
  // arguments: id of layer containing scrolling layers (clipped layer), id of layer to scroll,
  // if horizontal scrolling, id of element containing scrolling content (table?)
  var wndo = new dw_scrollObj('wn', 'lyr1', null);

  // pass id's of any wndo's that scroll inside tables
  // i.e., if you have 3 (with id's wn1, wn2, wn3): dw_scrollObj.GeckoTableBugFix('wn1', 'wn2', 'wn3');
  dw_scrollObj.GeckoTableBugFix('wn');
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

//-->
</script>
</head>
<body onload="initScrollLayer();MM_preloadImages('images/newsover.gif','images/printover.gif','images/musicover.gif'); loadposition()" >
<div id="bodyinner"></div>
<div id="container"><div id="logo"></div>
<div id="scroll"><br />

<table class="imgTbl" cellspacing="0" cellpadding="0" border="0">
	<tr>
	  <th colspan="3"> </th>
	</tr>
	<tr>
    <td colspan="3" class="text">
<!-- relative positioned layer that contains scrolling layers -->
<div id="hold">
  <div id="wn">
    <!-- scrolling layer here -->
	  <div id="lyr1" class="content">
    <!-- The images here are different sizes, so td height is set (in style sheet) to equalize those differences.
  The table cell height is set equal to the scroll distance per click.   -->

<!--#include file="database.asp"-->

<%
mySQL = "SELECT * FROM products where Categories = ""Work"" order by Ordering asc"
'response.write mySQL
'response.end
'Rs.Open mySQL, Conn
'Conn.Close
'Set Rs=Nothing
Set rs = Conn.Execute(mySQL)
%>

<%
if request("picture") = "" then 
%>
<%
else
mySQL = "SELECT * FROM products where ID = "&request("picture")&" "
'response.write mySQL
'response.end
'Rs.Open mySQL, Conn
'Conn.Close
'Set Rs=Nothing
Set rsPic = Conn.Execute(mySQL)
end if
%>



			<table id="imgTbl" border="0" cellpadding="0" cellspacing="0">
<tr> 
<%
i = 1
do until rs.eof
	if not i mod 3 = 0 then
		%><td>
        <a class="opacityit" href="#" onclick="javascript:showDiv(<%= rs("ID") %>)"><img border="0" src="productimages/<%=rs("Thumbs")%>" width="79" height="79" alt="<%=rs("Alt")%>" /></a>
        </td><%
	else
		%><td>
               <a class="opacityit" href="#" onclick="javascript:showDiv(<%= rs("ID") %>)"><img border="0" src="productimages/<%=rs("Thumbs")%>" width="79" height="79" alt="<%=rs("Alt")%>" /></a>

        </td></tr><tr><%
	end if		
i = i + 1
rs.movenext
loop
%> 
</table>       

	  </div>  <!-- end scrolling layer -->

</div>  <!-- end wn  -->
</div><!-- end hold (relative layer) -->
<div id="buttons2"><div align="left"><img src="images/button.gif" border="0" usemap="#Map" />
  <map name="Map">
    <area shape="rect" coords="2,3,59,30" href="javascript:;" onclick="dw_scrollObj.scrollBy('wn',0,92); return false">
    <area shape="rect" coords="63,2,130,46" href="javascript:;" onclick="dw_scrollObj.scrollBy('wn',0,-92); return false">
  </map>
</div></div></td>
    </tr>
</table>
<!--#include file="menu.asp"-->
<div id="centerpart">
<div id="hideshow" style="visibility:hidden;"> 
	<div id="fade"></div> 
	<div class="popup_block"> 
		<div class="popup"> 
            test
            
            <%
            request.querystring("id") 
            
            'Response.Write(showDiv + "<BR>\r")
            %>
		</div> 
	</div> 
</div> 
<%
if request("picture") = "" then 
%>
<%else%>
<style type="text/css">
@import "scripts/main.css";
</style>
<div id="centerpart">
<div id="hideshow" style="visibility:hidden;" onclick="function1()"> 
	<div id="fade"></div> 
	<div class="popup_block"> 
		<div class="popup"> 
test
		</div> 
	</div> 
</div> 

<br /><div id="des">
<%=rsPic("Description")%>


<br />
<div class="price"><!--€<%=rsPic("Price")%>,- --></div><div class="buy"><!--<input type="image" src="images/buy.gif" border=0 alt="Buy" class="submit">
  <img src="images/iDeal-logo.gif" alt="iDeal" width="21" height="19" class="ideallogosml" />--></div>

<input type="hidden" name="qty" value="1" size="1">
<input type="hidden" name="dir" value="<%=rsPic("Price")%>">
		<input type="hidden" name="add" value="<%=rsPic("Images")%>" size="1">
		<div id="inputhidden"><input type="hidden" name="des" value="<%=rsPic("Description")%>" ></div>
</form>
</div>
</div>

</div>
<%end if%>
</div></div>



</div>



</body>
</html>
 
Your javascript function showDiv() does not require a parameter. That function looks for a element called "hideshow" and sets its visibility style to "visible".

You may leave out <%= rs("ID") %>



test.asp:
Code:
html>
<head>

<script language=javascript type='text/javascript'>
    //function function1(){
    //document.getElementById('hideshow').style.visibility = 'hidden';
    //}
    function hideDiv() {
        if (document.getElementById) { // DOM3 = IE5, NS6
            document.getElementById('hideshow').style.visibility = 'hidden';
        }
        else {
            if (document.layers) { // Netscape 4
                document.hideshow.visibility = 'hidden';
            }
            else { // IE 4
                document.all.hideshow.style.visibility = 'hidden';
            }
        }
    }

    function showDiv() {
        if (document.getElementById) { // DOM3 = IE5, NS6
            document.getElementById('hideshow').style.visibility = 'visible';
        }
        else {
            if (document.layers) { // Netscape 4
                document.hideshow.visibility = 'visible';
            }
            else { // IE 4
                document.all.hideshow.style.visibility = 'visible';
            }
        }
    }
</script>

<%
for i = 1 to 3
        %>
         <a class="opacityit" href="#" onclick="javascript:showDiv()">Picture</a><br />

<% next %>


<div id="hideshow" style="visibility:hidden;">
The quick brown foxbox jumps over the lazy brown dog
</div>
</body>
</html>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top