Board index   FAQ   Search  
Register  Login
Board index php forum :: HTML JavaScript

OnChange doesn-t work !!!!

Javascript coding ..

Moderators: macek, egami, gesf

OnChange doesn-t work !!!!

Postby cho@ » Wed Sep 10, 2003 7:17 am

hi,

I have got my script like that

Code: Select all
<script language="JavaScript" type="text/javascript">
<!-- hide
var multimedia_C = new Array("database", "system_software", "media", "www_publishing", ) ;
var multimedia_I = new Array("nothing") ;
var multimedia_H = new Array("java_wireless", "intro_java", ) ;

function swapOptions(the_array_name)
{
var the_select = window.document.upload.modules;
var the_array = eval(the_array_name);
for (loop=0; loop < the_array.length; loop++)
{
the_select.options[loop].text = the_array[loop];
}
}
// show me -->
</script>


and so in my page to call these function I do:

Code: Select all
<select name="pathway" onChange="swapOptions(window.document.upload.pathway.options[selectedIndex].value);">

<option selected>-- choose a pathway --</option>
<option value="information-technology_C">Information Technology</option>
<option value="internet-technology_C">Internet Technology</option>
<option value="multimedia_C">Multimedia</option>
</select>


But this doesnt work....
I got an error like:

Line:140
char: 1
Error: Object Expected

and line 140 is the line with the onchange on it...
So I have tried just to check

Code: Select all
<select name="pathway" onChange="alert(window.document.upload.pathway.options[selectedIndex].value);">


And its working, I mean I got the value of the selected line...
So wot s wrong when I call this function... and the target select is existing...

ps: I v found this functions on

http://hotwired.lycos.com/webmonkey/98/04/index3a_page10.html?tw=programming

Thanks
francois
cho@
New php-forum User
New php-forum User
 
Posts: 39
Joined: Tue Aug 06, 2002 8:58 am
Location: UK

Postby pootergeist » Wed Sep 10, 2003 8:31 am

your arrays are named multimedia_C , _H and _I yet your option values are information-technology_C etc
pootergeist
New php-forum User
New php-forum User
 
Posts: 191
Joined: Wed Jan 29, 2003 7:11 am
Location: UK

Postby cho@ » Wed Sep 10, 2003 9:53 am

it is because i didnt put all my arrays (i have 9 of them, generated with a php scrpit)

multimedia_C,_I, _H
and same for information-technology and internet-technology

I have just for testing put the value at multimedia_C, ... for my select

In the final version it will have a select for the level (C, H, I) and a select for the subject (multimedia,...)
it will make a concat to give the name of the array....and then display the modules available....(the content of the corresponding array)

I think I gave all the info this time

francois
cho@
New php-forum User
New php-forum User
 
Posts: 39
Joined: Tue Aug 06, 2002 8:58 am
Location: UK


Return to JavaScript

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.