Advertisement

06.05.2008 at 06:28AM PDT, ID: 23460055
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.9

Switch div content onclick (multiple)

Asked by djfenom in JavaScript, Active Server Pages (ASP), Asynchronous Javascript and XML (AJAX)

Tags: , ,

I am creating a page (http://www.smokezone.arrivalpreview.co.uk/awnings.asp) which has a list of products populated from a database (ASP/Access). Within each product box is the option to view the Spec for that product. When this is clicked, the div content is replaced with different content from the database. This works for the first product, but I need it to work for all of them.

I would also like it to revert back to the original content either by clicking the Spec button or via another link somewhere.

The code on the page is:

  ** moved to snippet - b0lsc0tt **

Thanks

ChrisStart Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/szone.asp" -->
<%
Dim RSprod
Dim RSprod_numRows
 
Set RSprod = Server.CreateObject("ADODB.Recordset")
RSprod.ActiveConnection = MM_szone_STRING
RSprod.Source = "SELECT * FROM products"
RSprod.CursorType = 0
RSprod.CursorLocation = 2
RSprod.LockType = 1
RSprod.Open()
 
RSprod_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index
 
Repeat1__numRows = -1
Repeat1__index = 0
RSprod_numRows = RSprod_numRows + Repeat1__numRows
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>The S-Zone</title>
<link href="szone.css" rel="stylesheet" type="text/css" media="all" />
<script type="text/javascript" src="mootools.js"></script>
<script type="text/javascript" src="slideshow.js"></script>
<script type="text/javascript">
function GetXmlHttpObject(handler)
{ 
var objXmlHttp=null;
 
if (navigator.userAgent.indexOf("MSIE")>=0)
{ 
var strName="Msxml2.XMLHTTP";
if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
{
strName="Microsoft.XMLHTTP";
} 
try
{ 
objXmlHttp=new ActiveXObject(strName)
objXmlHttp.onreadystatechange=handler;
return objXmlHttp;
} 
catch(e)
{ 
alert("Error. Scripting for ActiveX might be disabled");
return;
} 
} 
if (navigator.userAgent.indexOf("Mozilla")>=0)
{
objXmlHttp=new XMLHttpRequest();
objXmlHttp.onload=handler;
objXmlHttp.onerror=handler;
return objXmlHttp;
}
} 
 
function GetSpec(id)
{ 
var url="getspec.asp?specID=" + id ;
 
xmlHttp=GetXmlHttpObject(stateChanged);
xmlHttp.open("GET", url , true);
xmlHttp.send(null);
} 
 
function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById('changer').innerHTML=xmlHttp.responseText;
}
} 
</script>
</head>
<body>
<div id="outer">
  <div id="container">
  <h1 class="hide">The S-Zone</h1>
    <div id="nav">
      <ul>
        <li><a href="index.html">Home</a></li>
        <li class="onstate"><a href="products.html">Products</a></li>
        <li><a href="services.html">Services</a></li>
        <li><a href="contact.html" class="cont_butt">Contact</a></li>
      </ul>
    </div>
	<div id="logo">
	  <h1><a href="index.html" title="The S-Zone"><span class="hide">The S-Zone</span></a></h1>
	</div>
    <div id="image"><img src="images/top-image1.jpg" width="518" height="232" alt="" /></div>
	<div class="cleaner"></div>
    <div id="content">
      <div id="leftcol">
      <h2><a href="products.html" title="Back to Product Range">Products</a> / <span class="grey">Awnings</span></h2>
        <p>Not  only does an awning offer protection for your customers it dramatically  transforms the appearance of your premises creating that &quot;Alfresco&quot;  atmosphere adding space and turnover.</p>
        <p>You  can choose from our extensive range of colours and patterns as well as  alternative operating systems. Your awning can be manually or electrically  operated. (Electric operation via either a security key switch or a hand held  remote control).</p>
        <p>All  our systems are manufactured to our high standards using years of experience.  They are all carefully designed to provide reliability and long life. Each  awning is assembled using top quality components and fabric, which with regular  maintenance can enhance your image.</p>
      </div>
      <div id="subnav">
        <ul>
          <li class="prodhead">Products:</li>
          <li><a href="awnings.asp">Awnings</a></li>
          <li><a href="parasols.html">Parasols</a></li>
          <li><a href="canopies.html">Canopies</a></li>
          <li><a href="smoking-shelters.html">Smoking Shelters</a></li>
          <li><a href="furniture.html">Furniture</a></li>
          <li><a href="heaters.html">Heaters</a></li>
          <li><a href="cafe-barriers.html">Caf&eacute; Barriers</a></li>
          <li><a href="accessories.html">Accessories</a></li>
        </ul>
      </div>
      <div class="cleaner"></div>
        
      <% 
While ((Repeat1__numRows <> 0) AND (NOT RSprod.EOF)) 
%>
        <div class="prodbox">
          <div class="prodbox_text">
            <div class="prodbox_intro">
              <h3><%=(RSprod.Fields.Item("prodTitle").Value)%></h3>
	          <div id="changer">
	            <p><%=(RSprod.Fields.Item("prodContent").Value)%></p>
              </div>
	        </div>
	        <ul>
	          <li><a href="javascript:GetSpec(<%=(RSprod.Fields.Item("prodID").Value)%>)" class="specs">Specs</a></li>
	          <li><a href="pdfs/<%=(RSprod.Fields.Item("prodPDF").Value)%>" class="price">PDF Price Guide</a></li>
	          <li><a href="<%=(RSprod.Fields.Item("prodInfo").Value)%>" class="info">Product Info</a></li>
	        </ul>
	        </div>
          <div class="prodbox_image"><img src="images/<%=(RSprod.Fields.Item("prodImage").Value)%>" alt="<%=(RSprod.Fields.Item("prodTitle").Value)%>" width="204" height="219" /></div>
          <div class="cleaner"></div>
        </div>
        <% 
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  RSprod.MoveNext()
Wend
%>
</div>
  </div>
</div>
<div id="footer">
  <ul>
    <li>&copy; Copyright The S Zone 2008</li>
    <li class="valid">Site Uses valid: <a href="http://validator.w3.org/check/referer" title="Validate XHTML">XHTML</a> | <a href="http://jigsaw.w3.org/css-validator/check/referer" title="Validate CSS">CSS</a> | <a href="site-map.html">Site Map</a></li>
  </ul>
</div>
<script type="text/javascript">
  window.onload = function() { myShow = new Slideshow('image', { type: 'fade', duration: [2000, 4000], images: ['image1.jpg', 'image2.jpg'], hu: 'images/' }); }
</script>
</body>
</html>
<%
RSprod.Close()
Set RSprod = Nothing
%>
 
The getspec.asp file is as follows:
 
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
strProvider = "Provider=Microsoft.Jet.OLEDB.4.0;"
strDb = "Data Source=" & Server.MapPath("db/szone.mdb")
strConn = strProvider & strDb
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open strConn
query = "SELECT * FROM products WHERE prodID = ?"
CustomerID = Request.QueryString("specID")
arParams = array(CustomerID)
set cmd = Server.CreateObject("ADODB.Command")
cmd.CommandText = query
set cmd.ActiveConnection = Conn
Set rs = cmd.Execute(,arParams,1)
If Not rs.EOF Then
	Response.Write "<dl>" & vbcrlf
	Response.Write "<dt>Sizes:</dt>" & vbcrlf
	Response.Write "<dd>" & rs("prodSize") & "</dd>" & vbcrlf
	Response.Write "<dt>Price:</dt>" & vbcrlf
	Response.Write "<dd>" & rs("prodPrice") & "</dd>" & vbcrlf
	if rs("prodOperation") <> "" then
	Response.Write "<dt>Operation:</dt>" & vbcrlf
	Response.Write "<dd>" & rs("prodOperation") & "</dd>" & vbcrlf
	end if
	if rs("prodExtra") <> "" then
	Response.Write "<dt>Extra:</dt>" & vbcrlf
	Response.Write "<dd>" & rs("prodExtra") & "</dd>" & vbcrlf
	end if
	Response.Write "</dl>" & vbcrlf
End If
rs.Close : Set rs = Nothing
set cmd = Nothing 
Conn.Close : Set Conn=nothing
%>
 
Loading Advertisement...
 
[+][-]06.05.2008 at 11:22AM PDT, ID: 21722468

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: JavaScript, Active Server Pages (ASP), Asynchronous Javascript and XML (AJAX)
Sign Up Now!
Solution Provided By: hielo
Participating Experts: 1
Solution Grade: B
 
 
[+][-]06.06.2008 at 01:23AM PDT, ID: 21727157

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.06.2008 at 06:45AM PDT, ID: 21728983

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.06.2008 at 06:52AM PDT, ID: 21729036

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.06.2008 at 08:02AM PDT, ID: 21729712

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.06.2008 at 10:24AM PDT, ID: 21731021

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628