Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Javascript / Client Side Development

Drop down setting


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

Sorted I had too many = 's

"Paul" <notha@btopenworld.com> wrote in message

news:KI-dnSvcY58GWdzbnZ2dnUVZ8turnZ2d@bt.com...
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

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);

--
Stephane Moriaux et son (moins) vieux Mac dj dpass

ASM said the following on 5/9/2007 9:15 AM:

> 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 !

Wanna bet?

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

Randy Webb a crit :

> Wanna bet?

quoi toi dire ?

--
Stephane Moriaux et son (moins) vieux Mac dj dpass

ASM wrote on 09 mei 2007 in comp.lang.javascript:

> Randy Webb a crit :

>> Wanna bet?

> quoi toi dire ?

How dire?

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

ASM said the following on 5/9/2007 1:44 PM:

> Randy Webb a crit :

>> Wanna bet?

> quoi toi dire ?

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?" and I am not
sure if you don't understand what I said or if it is a request for me to
win the wager I offered to make. Just a friendly wager on whether or not
I have to qualify formObj with document. before it. I don't.

<input type="button" onclick="someFunction(this.form)" value="Test It">

function someFunction(formObj){
alert('I have a reference to formObj without using document. first')

}

Give it some thought and reconsider your statement that it "at least ...
with document. in 1st place". Whether you need a document lookup depends
- directly - on how you obtain formObj to start with.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

Evertjan. a crit :

> ASM wrote on 09 mei 2007 in comp.lang.javascript:

>> Randy Webb a crit :
>>> Wanna bet?
>> quoi toi dire ?

> How dire?

do you mean 'document' is not necessary ?

--
Stephane Moriaux et son (moins) vieux Mac dj dpass
Stephane Moriaux and his (less) old Mac already out of date

Randy Webb a crit :

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

>>> Wanna bet?

>> quoi toi dire ?

> 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 ...

--
Stephane Moriaux et son (moins) vieux Mac dj dpass
Stephane Moriaux and his (less) old Mac already out of date

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?

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

Randy Webb a crit :

> ASM said the following on 5/9/2007 7:44 PM:

>> seen like that ...

> 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

--
Stephane Moriaux et son (moins) vieux Mac dj dpass
Stephane Moriaux and his (less) old Mac already out of date

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

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

>>> seen like that ...

>> 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

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 :)

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

"Randy Webb" <HikksNotAtH@aol.com> wrote in message

news:SrCdnU1oSart0d7b4p2dnA@giganews.com...

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

Randy Webb wrote:
> 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.

--
-Lost
Remove the extra words to reply by e-mail.  Don't e-mail me.  I am
kidding.  No I am not.

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc