PDA

View Full Version : div+writting+if statements = error


scroots
01-25-2003, 05:31 PM
couls somebody help me out with my code, i have

<script>
function a(k){
if(k==0){
a.innerHTML='<a href="#" OnClick="a(\'1\')">SECTION 1</A><a href="page.htm">SECTION A</A><a href="page.htm">SECTION B</A><a href="page.htm">SECTION C</A>'
}
if(k==0){
a.innerHTML='<a href="#" OnClick="a(\'0\')">SECTION 1</A>'
aa=0
}}
</script>


and

<td width="100%"><div id="a"><a href="#" OnClick="a('0')">SECTION 1</A></div></td>


when i click the section 1 link it should change the contents of the div using function a, when the link is clicked it should change the valuse of k to 0, so that the if statement is used to change the content to the correct content.

any ideas of how to solve my problem?
thanks in advance
scroots

ez4me2c3d
01-25-2003, 05:51 PM
this is what you need. tested.
<script>

function a(k) {
if (k==0) {
a2.innerHTML='<a href="javascript:a(1)">SECTION 1</a> <a href="page.htm">SECTION A</a> <a href="page.htm">SECTION B</a> <a href="page.htm">SECTION C</a>';
} else {
a2.innerHTML='<a href="javascript:a(0)">SECTION 1</a>';
}
}

</script>

<div id="a2"><a href="javascript:a(0)">SECTION 1</a></div>

oh yeah you can put your div inside your td, i just left it out so i didnt have to write table codes for testing

scroots
01-25-2003, 06:05 PM
thank you for your help, your solution has helped me a great deal in my understanding and learning of javascript.

cheers
scroots

ez4me2c3d
01-25-2003, 10:13 PM
you are very welcome, it's my pleasure to help others