Dynamic Placement

This is a discussion on "Dynamic Placement" within the JavaScript Forum section. This forum, and the thread "Dynamic Placement are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Sep 7th, 2005, 13:43
Junior Member
Join Date: Sep 2005
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Dynamic Placement

Here's the code:

<head>
<script language="javascript">
function Depshow()
{
if (document.Appraisal.Question2H.options[document.Appraisal.Question2H.selectedIndex].value=='1')
{
document.getElementById("Question2H21").innerHTML= "<tr <%=rowstyle%>><td>Dependant 1:<\/td><\/tr>";
}
else
{
document.getElementById("Question2H21").innerHTML= "";
}
}
</script>
<style>
.lightBG {
background-color: #dddffd;
}
</style>
</head>

<body>
<form name="Appraisal">
<% rowstyle = "class=lightBG" %>
<select name="Question2H" onChange="Depshow();">
<option value="">Please select</option>
<option value="1">1</option>
<option value="2">2</option>
</select>



<table border="0">
<tr><td>Line 1</td></tr>
<div id="Question2H21"></div>
<tr><td>Line 2</td></tr>
</table>
</form>
</body>
</html>

This has been stripped down as it was rather a long page. It's an ASP page where the row colour changes depending on which row it is (but that's been taken out here). I want the middle row in the table to be displayed if the user clicks 1 in the select menu, otherwise the middle row is to remain hidden. The above code does not show the line no matter what value is selected. If I change the code to have the <tr> and <td> tags around the <div> tag, the row does appear when it's suppose to but there is a small line of colour left when the row is hidden which my boss doesn't like. Does anyone know how I can get the row to appear as it should but to also leave no trace when it's hidden?
Reply With Quote

  #2 (permalink)  
Old Sep 7th, 2005, 17:13
Most Reputable Member
Join Date: Jul 2003
Posts: 1,856
Thanks: 0
Thanked 0 Times in 0 Posts
If you look at this example, the middle row exists it's just hidden with CSS:

Code: Select all
<table cellspacing="0" cellspacing="0" cellpadding="0" border="1">
<tr><td>a</td></tr>
<tr style="display:none;"><td>b</td></tr>
<tr><td>c</td></tr>
</table>
So rather than trying to add the row to the table using .innerHTML I'd recommend writing the row in from the start and hiding/showing it using CSS display:none; and display:show; and Javascript.
Reply With Quote
  #3 (permalink)  
Old Sep 8th, 2005, 10:45
Junior Member
Join Date: Sep 2005
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks Catalyst,

That worked a treat, had to tweak the display:show to a different value but other than that it was plain sailing.

Reply With Quote
Reply

Tags
dynamic, placement

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
a little help - image placement stupid dog Web Page Design 5 Jul 30th, 2007 17:49
New Adsense placement craig Webforumz Suggestions and Feedback 26 Dec 19th, 2006 19:22
Problem with CSS/Java graphic placement MikeX Web Page Design 4 Aug 21st, 2006 19:26
Strange text placement (IE) Tino Web Page Design 3 Aug 7th, 2006 15:10


All times are GMT. The time now is 10:45.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

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