Javascript question
by "Rajnish Bhaskar" <r.bhaskar(at)compserv.gla.ac.uk>
|
| Date: |
Thu, 28 Feb 2002 16:09:58 -0000 |
| To: |
hwg-languages(at)hwg.org |
| |
todo: View
Thread,
Original
|
|
Hi folks,
I have two select boxes (called oldTutor and newTutor) on a form both
containing the same list of tutors. What I want to do is that when
someone selects a value from the first, that value will disappear
from the second list.
Javascript isn't my first language (to put it mildly!), so I'm having
some problems.
At the top of the page, I try and store the list:
// store the original list of tutors
var tempOptions= document.forms[0].newTutor.options;
Then I set the onChange event as follows:
onchange="removeSelected(document.forms[0]);"
And the removeSelected() method says this:
function removeSelected(theForm)
{
// reset the second selectbox to the original values
for (var i=0; i<tempOptions.length; i++)
theForm.newTutor.options[i]= tempOptions[i];
var selIndex= theForm.oldTutor.SelectedIndex;
theForm.newTutor.options[selIndex]= null;
history.go(0);
} // end function removeSelected()
The thing is that I'm falling at the first hurdle -- when I first
load the page, the JS console tells me that document.forms has no
properties. Any ideas (or better ways of doing this)?
Thanks,
Raj.
--
Rajnish Bhaskar
r.bhaskar(at)compserv.gla.ac.uk, http://lordofthemoon.com
IT Education Unit, University of Glasgow
http://www.iteu.gla.ac.uk/
--
Thought for the day:
Dictatorship (n): a form of government under which everything
which is not prohibited is compulsory.
HWG: hwg-languages mailing list archives,
maintained by Webmasters @ IWA
This page is part of a preserved archive of archives.hwg.org. The site is no longer active and its content is not maintained. For enquiries about this archive, write to archive(at)iwanet.org.