Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Onchange display hidden id - problem
Old 12-04-2010, 06:53 PM Onchange display hidden id - problem
Gilligan's Avatar
Website Designer

Posts: 1,670
Name: Stefan
Location: London, UK
Trades: 0
I've setup a small script so that when the user selects a certain value from a select menu, another row in a table is displayed with some data.

HTML Code:
<form>
<table>
<tr>
<td>Form</td>
<td>
<select onchange="if (this.value == 'ValueHere') {
document.getElementById('IDofRow').style.display = 'block';
}
else {
document.getElementById('IDofRow').style.display = 'none';
}">
<option selected>Option 1</option>
<option value="ValueHere">Option 2</option>
<option value="AnotherValue">Option 3</option>
</select>
</td>
</tr>
<tr id="IDofRow" style="display:none;">
<td>Look at this</td>
<td>Test</td>
</tr>
</table>
</form>
The problem is that the positioning and width of the hidden <tr> and <td> is wrong for some reason. Please copy this code and try it out yourself to see what I mean.

I can't quite work out why it is doing this.

Any help is appreciated
__________________

Please login or register to view this content. Registration is FREE
Gilligan is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-06-2010, 06:32 AM Re: Onchange display hidden id - problem
Kelpie's Avatar
Skilled Talker

Posts: 82
Name: Andrew
Location: SW Scotland
Trades: 0
Your code is causing the table row to display as a block element instead of a row; instead of display = 'block' it should be display = 'table-row', but of course ie doesn't support this.
So instead since this IS a table row you can just use display = '' to reset it to its default display mode.

Last edited by Kelpie; 12-06-2010 at 06:49 AM.. Reason: Rewording
Kelpie is offline
Reply With Quote
View Public Profile
 
Old 12-07-2010, 06:26 PM Re: Onchange display hidden id - problem
Gilligan's Avatar
Website Designer

Posts: 1,670
Name: Stefan
Location: London, UK
Trades: 0
Worked a treat, thanks
__________________

Please login or register to view this content. Registration is FREE
Gilligan is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Onchange display hidden id - problem
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.14375 seconds with 12 queries