javascript - Hiding elements in a table -


i have html form in table. i'd elements hidden unless user writes "italy" in text field. script works fine in disabling text field i'd hide:

if (e.value == 'italy' && e.name == 'birth'){         document.getelementbyid('comune_nascita').disabled = false         document.getelementbyid('provincia_nascita').disabled = false     } else if (e.name == 'birth'){         document.getelementbyid('comune_nascita').disabled = true         document.getelementbyid('provincia_nascita').disabled = true             } 

live example: jsfiddle (try write "italy" in field "state of birth").

i don't want disable text field: i'd invisible.

so i've added <tr id='italy_b' style='display:none'> html element contains text field, , converted script this:

if (e.value == 'italy' && e.name == 'birth'){     document.getelementbyid('italy_b').style.display = 'block' } else if (e.name == 'birth'){     document.getelementbyid('italy_b').style.display = 'none' } 

however, try here , see error: jsfiddle. write "italy" in "state of birth" field, other text fields appear but go out of table!

how solve this? why going out of table?

it's simple, you're setting display: block on table row. table rows not block default, display: table-row. change , it'll work.

document.getelementbyid('italy_b').style.display = 'table-row'; 

jsfiddle: http://jsfiddle.net/xakh4/7/


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -