Jump to content

I heard there were some freaks around here... form thingy


mendoz

Recommended Posts

Hey Freaks.

Well, the situation is like this:
I have a form with an option box, which has "yes" and "no".

I'd thought it'd be cool if when "yes" is selected another table row (tr) would appear and disappear when "no" is selected.

Being a JS noob I need your help.

Thanks,
Dror
The example below has radio buttons to show/hide row 1 of the table.  The onClick event for each radio button sends the value of the radio button to the Javascript function, which uses that number to determine which row to show/hide.

[code]<form>
  <input type="radio" name="something" value="row1" onClick="showRow(this.value)" /> Yes
  <input type="radio" name="something" value="row1" onClick="hideRow(this.value)" /> No
</form>

<table>
  <tr id="row1" style="display:none;">
    <td>Test 1</td>
    <td>Test 2</td>
  </tr>
  <tr id="row2" style="display:none;">
    <td>Test 3</td>
    <td>Test 4</td>
  </tr>
</table>[/code]


[code]
function showRow(num) {
  document.getElementById(num).style.display = 'block';
}
function hideRow(num) {
  document.getElementById(num).style.display = 'none';
}[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.