carpetfrog-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org
2007-Jun-29 10:27 UTC
Unclear about something simple
I assume Form.Element.getValue() is what I use to get the value of an input field, but how do I simply set the value of an input field to something else? I need to change the text of an input field and also change the selected option of a dropdown. Would someone be able to show me what I would use for this, or do I need to use bog-standard JS? seems strange... --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Hey, carpetfrog-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org a écrit :> I assume Form.Element.getValue() is what I use to get the value of an > input field, but how do I simply set the value of an input field to > something else? I need to change the text of an input field and also > change the selected option of a dropdown.I believe Form.Element.setValue does the job! -- Christophe Porteneuve aka TDD tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
For form fields, I typically use the $F function and ensure that my input
field has an ID:
<input type="text" name="field1" id="field1"
/>
To get the value:
var value = $F(''field1'');
To set the value:
$(''field1'').value = "new value";
HTH,
Jon
On 6/29/07, carpetfrog-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org
<carpetfrog-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>
wrote:>
>
> I assume Form.Element.getValue() is what I use to get the value of an
> input field, but how do I simply set the value of an input field to
> something else? I need to change the text of an input field and also
> change the selected option of a dropdown.
>
> Would someone be able to show me what I would use for this, or do I
> need to use bog-standard JS? seems strange...
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
To change the SELECT, do the following:
$(''field1'').selectedIndex = n
Make sure the SELECT has an ID tag of ''field1''
On Jun 29, 6:27 am,
"carpetf...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org"
<carpetf...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>
wrote:> I assume Form.Element.getValue() is what I use to get the value of an
> input field, but how do I simply set the value of an input field to
> something else? I need to change the text of an input field and also
> change the selected option of a dropdown.
>
> Would someone be able to show me what I would use for this, or do I
> need to use bog-standard JS? seems strange...
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
> I believe Form.Element.setValue does the job!That''s in trunk only though. Regards, Tobie --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---