[thelist] Another Netscape problem
Jagjeet Hayer
Jagjeet.Hayer at softwareag.co.uk
Wed Aug 23 03:03:36 CDT 2000
dave,
Thanks for your help.
I think I may have solved it, although I am getting another error which may
or may not be related.
I have put a layer tag around the Select box. But you also need a form tag
around the select box to ensure Netscape and IE can get at it. Than onLoad
of the page I change the style to hidden depending on what the browser is.
Then an onChange in the other Select box obtains the value of the option
like this:
<script language=JavaScript">
function hideSelect()
{
if (vertype()=="ie")
{
document.layerform.select1.style.visibility = "hidden";
}
if (vertype()=="nav")
{
document.layer1.visibility = "hide";
}
}
function getOption()
{
if (vertype()=="ie")
{
optionValue =
document.layerform.select1.options[document.form1.select2.selectedIndex].val
ue;
}
if (vertype()=="nav")
{
optionValue =
document.layer1.document.layerform.select1.options[document.form1.select2.se
lectedIndex].value;
}
}
</script>
<body>
<layer id=layer1>
<form name=layerform>
<SELECT id=select1 name=select1></SELECT>
</form>
</layer>
<form name=form1>
<SELECT id=select2 name=select2 onChange="getOption();"></SELECT>
</form>
</body>
My problem was in using the <layer> and then the DOM to obtain the option
from the <select> as it is so different in IE and Netscape.
Jag.
> -----Original Message-----
> From: thelist-admin at lists.evolt.org
> [mailto:thelist-admin at lists.evolt.org]On Behalf Of dave gray
> Sent: 22 August 2000 21:10
> To: thelist at lists.evolt.org
> Subject: RE: [thelist] Another Netscape problem
>
>
> On Tue, 22 Aug 2000, Jagjeet Hayer wrote:
> > Ok, here goes. The select box is dynamically populated from a
> servlet. I
> > then need to retrieve one of these values depending on what the
> user selects
> > from another select box which is displayed on the screen.
>
> so would the code to generate the select box look like:
> <select name=select1>
> <!-- insert server-parsed code here -->
> </select>
>
> ?
>
>
> > So I want the first select box to be hidden because it is there
> purely as a
> > data element.
>
> i don't understand why you have to use that hidden select box to store
> your data... i think things would be a lot easier for you if you used a
> javascript array as your data element, like so:
>
> <input type=hidden name=select1 value="default">
> <select name=select2
> onchange="makeItSo(this.selectedIndex);">
> <option value="whatever" selected>
> </select>
>
> <script language="javascript" type="text/javascript">
> <!--
> // i don't know if this would actually work to have an array
> // declaration split up like this over several lines...
> var optionArray = ('<!-- insert server-parsed code here -->',
> '<!-- insert server-parsed code here -->');
>
> function makeItSo(val) {
> document.forms[0].select1.value=optionArray[val];
> }
> makeItSo(document.forms[0].selected2.selectedIndex);
> // -->
> </script>
>
> so that you pull the values out of the servlet and put them into a
> javascript array which you grab them back out of when your visible select
> box is changed
>
> if you have any more questions, feel free to ask, or if i'm not
> understanding your problem, let me know that too :)
>
> HTH
>
> -dave
More information about the thelist
mailing list