I'm having trouble with this code, i can't find the error.
Does anyone else see one?
please help it would be very much aprecciated.
Does anyone else see one?
| Code: |
| <html>
<head> <script type="text/javascript"> //changeing the text function changeit() { var myvar=document.getElementById('slct2').value if (myvar>1) { document.getElementById('td2').value=document.getElementById('mytext1').value; alert('the text was changed'); } else { document.getElementById('td1').value=document.getElementById('mytext1').value; alert('the text was changed'); } } function alertInnerHTML() //displaying function { var slct=document.getElementById("text1").value; //set the value to check if (slct>1) { alert("You selected 2"); alert(document.getElementById("td2").innerHTML); //alert row 1 column 1 } else { alert(document.getElementById("td1").innerHTML);//alert row 1 column 2 } } </script> </head> <body> <table border="1"> <tr> <th>Firstvalue</th> <th>Secondvalue</th> </tr> <tr> <td id="td1">Myfirstvalue</td> <td id="td1">mysecondvalue</td> </tr> </table> <br /> <p> select the number of the value you want to display.</p> <br /> <input type="button" onclick=alertInnerHTML() value="Alert innerHTML" /> <select id="slct1"><option>1</option><option>2</option></select> <br /> <p> Or, you can select the number of the text and change it</p> <br /> <input type="button" value="change value" onclick="changeit()"/> <select id="slct2"><option>1</option><option>2</option></select> text to change it to:<input type="text" id="mytext1" /> <br /> <p id="message"><p> </body> </html> |
please help it would be very much aprecciated.
