homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

Adding tr, DOM or display:none ?

5+ Year Member

Msg#: 3598966 posted 9:58 pm on Mar 12, 2008 (gmt 0)

I want to add a tr with inputs after a tr with inputs, based on those inputs. Is it better to add the tr and inputs with Javascript or would it be better to just display:none until it's needed?

I have a onchange event calling a function that I'm trying to build that will make the needed row and inputs. Is there a way to return to the function what tow the input is in, like with the 'this' keyword?



5+ Year Member

Msg#: 3598966 posted 4:44 am on Mar 13, 2008 (gmt 0)

You are suggesting that the rows are already filled out with input tags, and that some rows are hidden and some are not. You want to reveal certain rows, and not others, based on which input is being used, or what is being entered there? That means you are examining the control with every keypress. Or is that your use of the, onchange? Paste the code that you are using. As for the context word, this, you could work out to the first TR, and get its id, or assume next-sibling, or however you imagine it. But as you are already polling the control, basically, you know its id. You could put together an object, a table, for various input tag ids and what row they are in, if row is important.


5+ Year Member

Msg#: 3598966 posted 1:39 am on Mar 14, 2008 (gmt 0)

This works nicely with carriage return after entering/changing data in the first input, but it doesn't work well if tab is used.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html>
<meta http-equiv = 'Content-Type' content = 'text/html; charset = UTF-8'>
<tr id='tr1'><td><input id='in11' class='show' value='val1' onchange="(x=document.getElementById('in21')).className='show';x.focus()"></td></tr>
<tr id='tr2'><td><input id='in21' class='hide' value=''></td></tr>

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved