![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Programming Guru
![]() |
<html>
<head>
<html>
<head>
<link href="theme/Master.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
function changeTxt(){
document.write(document.all.secLvl.selectedIndex);
if (document.all.secLvl.selectedIndex == "1"){
document.all.test1.innerHTML = "rar this works";
}else{
document.all.test1.innerHTML = "nay it dont";
}
}
</script>
</head>
<body>
<form name="test">
<select name="secLvl" width="5" onChange=changeTxt() >
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<div id="test1">this is a test</span>
</form>
</body>
</html>I want it so that when someone selects an option the text changes accordingly i had it working so the text changed but the comparison is not working and so therefore always gives teh second result instead of the first one when you go on the 1 option...
__________________
"Put your hand on a hot stove for a minute, and it seems like an hour. Sit with a pretty girl for an hour, and it seems like a minute. THAT'S relativity." - Albert Einstein |
|
|
|
|
|
#2 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
First of all, div tags end in </div>, not </span>. And instead of using document.all.blah, use document.getElementById("blah").
|
|
|
|
|
|
#3 |
|
Programming Guru
![]() |
fair enough i did know the end div tag thingy i was just being gay and tried to use span fiorst, but still i cant get the current value from the list box
__________________
"Put your hand on a hot stove for a minute, and it seems like an hour. Sit with a pretty girl for an hour, and it seems like a minute. THAT'S relativity." - Albert Einstein |
|
|
|
|
|
#4 |
|
Programming Guru
![]() |
<html>
<head>
<html>
<head>
<link href="theme/Master.css" rel="stylesheet" type="text/css" />
<script LANGUAGE="JavaScript">
function changeTxt(){
Item = document.test.MOO.selectedIndex;
document.write(Item);
if (Item == 0){
document.getElementById("test1").innerHTML = "rar this works";
}else{
document.getElementById("test1").innerHTML = "nay it dont";
}
}
</script>
</head>
<body>
<form name="test" action="" method="get">
<select name="MOO" width="5" onChange=changeTxt() >
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<div id="test1">this is a test</div>
</form>thats my javascript.html exactly as it is on the tin. the error i am getting is Line : 15 Char: 3 Error : 'document.getElementById(...)' is null or not an object Code: 0 URL: about:blank
__________________
"Put your hand on a hot stove for a minute, and it seems like an hour. Sit with a pretty girl for an hour, and it seems like a minute. THAT'S relativity." - Albert Einstein |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|