SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist
    Join Date
    Feb 2005
    Location
    London, UK
    Posts
    422
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    load image in this span on page open

    click on the property you see listed on this page..
    http://heathrowminicab.com/falconwood/properties.asp

    the pop up opens up and using the property id loads the data for that record.

    in this pop up there is a javascript application, when the user clicks on one of the small images.. it loads full size in the span..

    now i didnt write this javascript.. someone in a forum wrote it for me.. i have been able to edit it to suit my layout requirements..

    my problem is that when the page loads, the span is empty..

    i need an image to load in the span immediately as it looks wrong when it loads..

    the picture i want loaded is 'out2' from my database..if anyone knows how to do this i would be very happy.. i tried just placing an img tag in the span but that didnt work.. thanks.

    Code:
    <%@ LANGUAGE=VBSCRIPT %>
    <%Option Explicit%>
    
    <%
    Dim adoCon
    Dim rsProperty
    Dim strSQL
    Dim lngRecordNo
    Dim sdesccolumn
    Dim ldesccolumn
    
    lngRecordNo = CLng(Request.QueryString("ID"))
    
    Set adoCon = Server.CreateObject("ADODB.Connection")
    adoCon.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("properties.mdb") & ";Persist Security Info=False"
    Set rsProperty = Server.CreateObject("ADODB.Recordset")
    strSQL = "SELECT properties.id, properties.type, properties.rooms, properties.rent, properties.area, properties.address, properties.rooms, properties.shortdesc, properties.longdesc, properties.small, properties.out1, properties.out2, properties.in1, properties.in2, properties.in3, properties.in4, properties.display FROM properties WHERE properties.id=" & lngRecordNo
    rsProperty.Open strSQL, adoCon
    sdesccolumn = rsProperty("shortdesc")
    ldesccolumn = rsProperty("longdesc")
    
    DIM strImage(5), a, b
    strImage(0) = rsProperty("out1")
    strImage(1) = rsProperty("out2")
    strImage(2) = rsProperty("in1")
    strImage(3) = rsProperty("in2")
    strImage(4) = rsProperty("in3")
    strImage(5) = rsProperty("in4")
    
    for a = 0 to 5
    	if IsNull(strImage(a)) then
    		strImage(a) = ""
    	end if
    next
    %>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>Chosen Property</title>
    <link rel="stylesheet" type="text/css" href="propertystyle.css">
    
    <script language="javascript">
    function showfullimage(ipath) {
    	var ispan = "";
    	ispan += ("<img src='" + ipath + "' border='0' />");
    	document.getElementById("imgspan").innerHTML = ispan;
    }
    </script>
    </head>
    <body>
    
    <div id="header">
    </div>
    
    <div id="left">
    <p class="topdesc"><%=rsProperty("address") & ", " & rsProperty("area")%></p>
    <span class="spam" id="imgspan"></span>
    <p class="placeinterest">Place an interest in this property:</p>
    <form class="interest" name="form1" method="post" action="sendmail.asp" onSubmit="return DataValidation()">
            <p class="formtext">Contact Name:</p>
              <input class="txtbox" name="contact" type="text" id="email" size="30"/>
            <p class="formtext">Email Address/Telephone No:</p>
              <input class="txtbox" name="email" type="text" id="Contact" size="30"/>
    		<br>
           <input class="formbutton" type="submit" name="Submit" value="Submit">
    </p>
          </form>
    </div>
    
    <div id="right">
    <p class="price"><%=rsProperty("rooms") & " " & rsProperty("type") & " - " & formatCurrency(rsProperty("rent"))%> (p.c.m)</p>
    <p class="longest"><%=rsProperty("longdesc")%></p>
    <table align="left" width="251" cellspacing="0" cellpadding="0" border="0">
    	<tr>
    		<td align="left" valign="top" width="240">
    			<table align="left" width="120" border="0">
    				<%b = 1
    				for a = 0 to 5
    					if strImage(a) <> "" then
    						if b = 1 then
    							%><tr><%
    						end if
    						%><th align="left" width="120"><img class="choice" src="<%=strImage(a)%>" border="0" width="70" height="50" onmouseover="this.style.cursor='Hand'" onclick="showfullimage(this.src);" /></th><%
    						if b < 2 then
    							b = b + 1
    						else
    							if a < 5 then
    								b = 1
    							else
    								b = 2
    							end if
    							%></tr><%
    						end if
    					end if
    				next
    				if b = 1 then
    					%><td></td>
    					</tr><%
    				end if%>
    			</table>
    		</td>
    		<th valign="bottom">
    		<a href="javascript: self.close()"><img class="closing" src="close.gif"/></a>
    			</th>
    	</tr>	
    </table>
    
    </div>
    
    <div id="footer">
    </div>
    </body>
    </html>

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    When you click on one of the small images, it calls the javascript function showfullimage with the url of the image to display. What you need to do is the same thing when the page loads. The ASP variable strImage(1) contains the image URL for "out2", so adding the following inside the <script> tags should do what you need:

    window.onload = function() {
    showfullimage("<%=strImage(1)%>");
    }

  3. #3
    SitePoint Evangelist
    Join Date
    Feb 2005
    Location
    London, UK
    Posts
    422
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thank you very much it worked..


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •