473,396 Members | 2,009 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Show/Hide Database entry

Hello,

I am trying to create a small post forum that via a database, the asp code displays a topic, author, and date submitted. on clicking the post, the messages of the user appears.
I tried to write a javascript function to perform the show/hide feature. I can make it work with only text
Expand|Select|Wrap|Line Numbers
  1. <p class="posthidden" id="showhide">msg: some text</p>
  2.  
but not with the database field
Expand|Select|Wrap|Line Numbers
  1. <p class="posthidden" id="showhide">msg: <% 'response.write(rs("comments")) %></p>
  2.  
I added two bitmaps that show what I am trying to do, any help would be appreciated

Below is my code:
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title>Update Entry Select</title>
  5. <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
  6.  
  7.  
  8. <script type="text/javascript">
  9. function expandcollapse (postid) {
  10. whichpost = document.getElementById(postid);
  11. if (whichpost.className=="postshown") { whichpost.className="posthidden"; }
  12. else { whichpost.className="postshown"; }
  13. }
  14. </script>
  15. <style type="text/css">
  16. .posthidden {display:none}
  17. .postshown {display:inline}
  18. </style>
  19. </head>
  20.  
  21. <body dir="rtl">
  22. <%
  23. 'Dimension variables
  24. Dim adoCon 'Holds the Database Connection Object
  25. Dim rs 'Holds the recordset for the records in the database
  26. Dim strSQL 'Holds the SQL query for the database
  27.  
  28. 'Create an ADO connection odject
  29. Set adoCon = Server.CreateObject("ADODB.Connection")
  30.  
  31. 'Set an active connection to the Connection object using a DSN-less connection
  32. adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("forum.mdb")
  33.  
  34. 'Set an active connection to the Connection object using DSN connection
  35. 'adoCon.Open "DSN=forum"
  36.  
  37. 'Create an ADO recordset object
  38. Set rs = Server.CreateObject("ADODB.Recordset")
  39.  
  40. 'Initialise the strSQL variable with an SQL statement to query the database
  41. strSQL = "SELECT * FROM FORUM_MESSAGES;"
  42.  
  43. 'Open the recordset with the SQL query
  44. rs.Open strSQL, adoCon
  45.  
  46. %>
  47. <table>
  48.    <tr>
  49.      <td>
  50.      <p style="width: 330px">Topic</p>
  51.      </td>
  52.      <td>
  53.      <p style="width: 274px">Author</p>
  54.      </td>
  55.      <td style="width: 271px">
  56.      <p>Date</p>
  57.      </td>
  58.    </tr>
  59.    <%
  60.    'Loop through the recordset
  61. Do While not rs.EOF
  62. %>
  63.    <tr>
  64.      <td>
  65.        <a href="javascript:expandcollapse('showhide')"><% response.write(rs("Topic")) %></a>
  66.        <p class="posthidden" id="showhide">msg: <% 'response.write(rs("comments")) %></p>
  67.       </td>
  68.       <td>
  69.        <% response.write(rs("AuthorName")) %>
  70.       </td>
  71.       <td style="width: 271px">
  72.        <% response.write(rs("LastThreadPost")) %>
  73.       </td>
  74.     </tr>
  75.  
  76. <%
  77. 'Move to the next record in the recordset
  78. rs.MoveNext
  79. Loop
  80. %>
  81. </table>
  82. </body>
  83. </html>
Attached Images
File Type: jpg dbase.jpg (3.8 KB, 146 views)
File Type: jpg dbase1.jpg (7.5 KB, 138 views)
May 3 '10 #1
1 1865
jhardman
3,406 Expert 2GB
what does the resulted html code look like? the answer has to be there.

Jared
May 6 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Ajai Kumar .R | last post by:
Hai all, I've two or more forms on my app. My requirement is, Have to show the first form asa the user press a button have to hide the first form and show the second form. If the user press the...
10
by: oLE | last post by:
I would like to add some javascript to show/hide a certain row of a table. The first row of the table contain the hyperlink that calls the javascript the second row is the one i want to show/hide...
3
by: alex | last post by:
I'd like to have a show/hide widget on my web site, kind of like "show details" / "hide details" in Google Groups. Is there a tutorial explaining how to make them? Google's is a bit complex and...
4
by: bridgemanusa | last post by:
Hi All: I have a very long page of html that I want to take portions and hide them in divs, then show when a link is clicked. I have the hide show part working when the link is clicked, however...
7
by: FP | last post by:
I'm new to Java Script. I'm displaying comments people have made. Below each persons' comment I want to add 2 buttons "Reply" and "Amend". Clicking "Reply" would display an empty text field...
3
by: | last post by:
I'm using the DataList and GridView controls, and I am trying to wrap my head around the problem of conditionally showing or hiding cells/cell content based on the presence or absence of DB data. I...
1
by: asilverpeach | last post by:
Hey Guys! Found some great scripts here on this topic but have to make to changes to the code that I can't seem to figure out. First, In the following code clicking on the headers shows the...
1
by: pamate | last post by:
hi, I want to show hide layers. I am able to show and hide layers but i am facing problem that, cant view the cursor in Mozilla,but i can type in input text box, its overlapping the layers. ...
0
by: gnewsgroup | last post by:
Well, I am trying to use the footer row of a GridView for insertion purpose. There are some articles about this, for example, the gridviewguy.com has an example, which always displays the footer...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.