Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Oct 5th, 2004, 8:26 AM   #1
Berto
Programming Guru
 
Join Date: Aug 2004
Posts: 1,022
Rep Power: 5 Berto is on a distinguished road
Send a message via AIM to Berto Send a message via MSN to Berto
<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
Berto is offline   Reply With Quote
Old Oct 5th, 2004, 1:54 PM   #2
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
First of all, div tags end in </div>, not </span>. And instead of using document.all.blah, use document.getElementById("blah").
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Oct 6th, 2004, 2:09 AM   #3
Berto
Programming Guru
 
Join Date: Aug 2004
Posts: 1,022
Rep Power: 5 Berto is on a distinguished road
Send a message via AIM to Berto Send a message via MSN to Berto
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
Berto is offline   Reply With Quote
Old Oct 6th, 2004, 6:56 AM   #4
Berto
Programming Guru
 
Join Date: Aug 2004
Posts: 1,022
Rep Power: 5 Berto is on a distinguished road
Send a message via AIM to Berto Send a message via MSN to Berto
<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
Berto is offline   Reply With Quote
Old Oct 6th, 2004, 10:51 AM   #5
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Then I have no idea - that code should work, apart from one thing - you have to define Item using var Item.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:32 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC