Drop down setting

P

Paul

How do I change the selected value of a dropdown list. I need to force this
as if another part of the form changes this should change in sympathy.

I have tried formObj.status.options[4].selected == true, but this doesn't
work
 
P

Paul

Sorted I had too many = 's


How do I change the selected value of a dropdown list. I need to force this
as if another part of the form changes this should change in sympathy.

I have tried formObj.status.options[4].selected == true, but this doesn't
work
 
A

ASM

Paul a écrit :
How do I change the selected value of a dropdown list. I need to force this
as if another part of the form changes this should change in sympathy.

I have tried formObj.status.options[4].selected == true, but this doesn't
work

It is at least :

document.formObj.status

with 'document' in 1st place !

and better :
document.forms['formObj'].elements['status']
where 'formObj' and 'status'
are the names of the form and of its element
ARE NOT THE ID ! ! !


Do you want : show item 5 ?

document.formObj.status.selectedIndex = 4;

or : give a new value and new text to that item ?

document.formObj.status.options[4].value = 'something.htm';
document.formObj.status.options[4].text = 'something';

or : whatelse ?

if(document.formObj.status.selectedIndex == 4)
alert(document.formObj.status.options[4].value);
 
A

ASM

Randy Webb a écrit :
ASM said the following on 5/9/2007 1:44 PM:

I can barely copy/paste French into a translator so I am not sure what
you are asking. It translates, roughly, to "What you say?"

ekzacktelly ! :)
and I am not
sure if you don't understand what I said

right : I don't understand wanna nor gonna and so on.
function someFunction(formObj){
alert('I have a reference to formObj without using document. first')
}

seen like that ...
 
A

ASM

Randy Webb a écrit :
ASM said the following on 5/9/2007 7:44 PM:

Then you agree with my assessment that document. is not "necessary" but
it is dependent on how you get formObj?

Yesss'Sir !

but you as me never will now what was 'formObj' in the question
 
P

Paul

Randy Webb said:
ASM said the following on 5/10/2007 11:04 AM:

That is true, but, it is also the reason you can't apply a blanket answer
to it as you don't know how it was obtained. If it was using the IE
shortcut of ID/NAME as a global variable then it could almost be expected
to have been elementObject.value and forget about the form object :)

Just so you don't lose any sleep 'formObj' was the name of the form passed
to the JS on the call to the function.

Cheers

Paul
 
L

-Lost

Randy said:
ASM said the following on 5/09/2007 9:15 AM:
and better :
document.forms['formObj'].elements['status']
where 'formObj' and 'status'
are the names of the form and of its element
ARE NOT THE ID ! ! !
but you as me never will now what was 'formObj' in the question

That is true, but, it is also the reason you can't apply a blanket
answer to it as you don't know how it was obtained. If it was using the
IE shortcut of ID/NAME as a global variable then it could almost be
expected to have been elementObject.value and forget about the form
object :)

I am surprised you did not say something about "ARE NOT THE ID." You
are the one who showed me that it works on either name or ID.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,161
Messages
2,570,892
Members
47,431
Latest member
ElyseG3173

Latest Threads

Top