Click to See Complete Forum and Search --> : beginner pbm
littleB
07-23-2003, 06:23 AM
Hi all
I have a pbm with netscape.
My script doesn't recognize this test :
if (griem1.elements['combo'].selectedIndex > 0)
it doesn't recognize this neither :
griem1.elements['combo'].options[griem1.elements['combo'].selectedIndex].value
This comes from a simple hmtl select.
I just want to test the value and pass it to another page.
My script works perfectly on IE, but NN is a little more capricious I guess...
I usually develop in C++, and i totally discovered javascript and html some days ago. That may explain my difficulties...
Please, help :)
Charles
07-23-2003, 06:28 AM
Please post the URL. We may be psycho but we're not psychic.
littleB
07-23-2003, 06:33 AM
Don't know if you will access to it, because it's a test machine on a specific network domain, but we can test :
http://molat2/~stef/griem/fr/lambda.php?element=Mg
I thought that specific pbm was commun and there was no utility to put the url
Anyway, if it doesn't work, i'll put it on another server. But i need a machine wich run apache and mysql.
Charles
07-23-2003, 06:42 AM
Nope, I cannot access it.
littleB
07-23-2003, 06:51 AM
this won't be complete (all the php and db is down on this server), but i just want, when you press the "valider" button, to store the selectedIndex value corresponding to the selected item in a variable. I guess the html source will be suffisant to this.
In NN, it simply stays empty...
http://mapage.noos.fr/~s.gouriou/griem/lambda.php
littleB
07-23-2003, 06:53 AM
Or tell me if there's differences between IE and NN in the way to get the selected index from a combo-box.
littleB
07-23-2003, 09:53 AM
My question was really simple in fact.
Here is the answer :
oelement = document.getElementById("combo");
var selindex = oelement.value;
Can't understand that no one has thinked about it... I do javascript for 2 days, but that seems so stupid to me...
Guess no one really take care about my question...
Charles
07-23-2003, 09:57 AM
Just haven't had the time to look carefully at it.
1) That can also be written var selindex = document.getElementById("combo").value;
2) You should remove the prepended "javascript:" from your event handler. It's an error that some browsers ignore.
littleB
07-23-2003, 10:08 AM
I just tested it on NN 4.x and it doesn't work...
Could you tell me if you have an idea to get the value of the selectedIndex in that old version ?
Charles
07-23-2003, 12:02 PM
There are two ways to access form elements and Netscape 4 doesn't implement the "document.getElementById()" way. But don't worry about it. Only about 1% of users use that browser but your script will fail for between 6 and 12% of MSIE users. And there's nothing that you can do about that so make sure that your page works as well with as without JavaScript.