Simple question! No Answer! The 2nd

Hi,

I have a simple problem! Javascript:

Here is the code:

var f=document.forms[0];

var pack=f.paket.value;

alert(pack);

When i run it on firefox it gets the value of field paket, and when i run it with IExplorer no value comes at all!

The code is placed in JSHeader on the form!

Thanks

Branimir

Subject: Simple question! No Answer! The 2nd

If you put the code in the JSHeader, it is executed before the page has fully loaded. And in that case f.paket is not yet known to the script.

Place the script at the end of the page and it will work.

Regards,

René

Subject: RE: Simple question! No Answer! The 2nd

Hi Rene

I have placed it on the bottom of my Javascript in JSHeader it still wont work!

The problem is that IE doesnt get the value from the field at all, the field is an combobox! The form is created in notes!

Is there any other way for me to stop the form from submit if there is an explicit value in the combobox!

Please help me

Branimir

Subject: RE: Simple question! No Answer! The 2nd

Aah. Thats is some information you might have mentioned earlier :wink:

You probably do not use aliases. In that case, IE returns an empty value.

Try:

var f=document.forms[0]

alert(f.paket[f.paket.selectedIndex].text)

Or use aliases. In that case you can use f.paket.value for both IE and Firefox.

Subject: RE: Simple question! No Answer! The 2nd

Thaaaaaaanks Rene!

You have been a great help to me! I have spent two past days trying and nooene could help me!

It works now!

Could you explain me how it works!

Is it ok if i mail you with notes problems that i got! I am quite new in this!!

Thanks

Branimir

Subject: RE: Simple question! No Answer! The 2nd

You’re welcome.

For using aliases in a combo-box field: check the help “Creating aliases for choices in a list”. That is pretty straight forward.

When you use an alias like

This is the text | Alias

it is translated to HTML as

This is the text

Now you can use document.forms[0].fieldName.value to get the value.

If you do not use an alias

This is the text

it is translated to HTML as

This is the text

In this case you cannot get the value with document.forms[0].fieldName.value (at least not in IE) but you have to use document.forms[0].fieldName[document.forms[0].fieldName.seletedIndex].text.

You can mail me but I don’t always have time to look at otherones problems (have enough of them of my own :wink: ). Best -and fastest- way to get an answer is to post it at this forum. There’s a lot of people looking at it so it is your best shot (even if your last experience was not that good, most of the time problems do get solved here)

Regards,

René