...

View Full Version : Change table based on check box?



botsko.net
01-17-2004, 09:11 PM
I am not quite sure what to look for on the net - that's why I cannot quite find how to do this.

Basically I have an html table with one input checkbox. If the check box is checked, I need two select drop-down menus to appear on the page.

If the check box is NOT checked, then just display one select-box drop-down.

I would like to enable the user to toggle back and forth (check it and uncheck it to change the page instantly).

What exactly should I learn/look for on the net in order to develop this?

scroots
01-17-2004, 10:16 PM
<div id="div1"><p>Start Text</p></div>
<input type="button" onClick="foo();" value="Click me to changethe start Text">

function foo(){
div1.innerHTML='<p>my new text</p>';
{


scroots

botsko.net
01-17-2004, 11:47 PM
This only seems to support IE. It works, and I am thankful to have a start.

1.) How can I change it to switch back when clicked a second time?

2.) Why doesn't it work in NetScape/Mozilla?

The mozilla javascript debugger reports:

error: div1 not defined.

The final code I have is:


<div id="div1"><p>Start Text</p></div>
<input type="button" onClick="foo();" value="Change">
<script language="javascript">
function foo(){
div1.innerHTML='<p>my new text</p>';
}
</script>

scroots
01-18-2004, 10:08 AM
var clicked=0;
function foo(){
if(click==0){
alert('click1');
click=1;
}else{ //then click is not 0
alert('click2');
click=0;
}



if you run that once it will alert click 1, run it twice it will alert click 1 and click 2, three times it will alert click1,click2 and then click1.

scroots

glenngv
01-19-2004, 09:03 AM
Originally posted by botsko.net

2.) Why doesn't it work in NetScape/Mozilla?


IE makes the element ids and names as global variables. :rolleyes:

You should reference it the proper way like this:

function foo(){
document.getElementById('div1').innerHTML='<p>my new text</p>';
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum