[Javascript] Dollar function for name=
Terry Riegel
riegel at clearimageonline.com
Wed Jun 2 08:40:12 CDT 2010
On Jun 2, 2010, at 12:38 AM, Scott Reynen wrote:
> On Jun 1, 2010, at 3:07 PM, Terry Riegel wrote:
>
>> I want to be able to do something like...
>>
>> $name(n).value="sausage";
>>
>> In the case of a radio button it would be to set the radio whose name is pizza and whose value is sausage to selected
>>
>> I will have to think through how this may/may not work. It is really something specific to my thinking and for me to be able to create a convenience function to let me address elements by their name instead of having to create an ID for all of them.
>>
>> So in the case of an input I am thinking in terms of an "pseudo" object/elment that will let me deal with all the radio buttons as a single object/element.
>
>
> I'm not generally one to point to frameworks when the question is about JavaScript, but your phrasing just screams framework. Pseudo-elements to refer to multiple elements is exactly what JavaScript frameworks provide. Here's how you'd do this in jQuery, for example:
>
> $('[name=n]').val('sausage');
>
> Peace,
> Scott
Exactly, the frame work I use is prototype, but I have not been able to find this kind of functionality. So I thought I would try to develop it. :)
Terry
More information about the Javascript
mailing list