OK, if I got this right and I don't think I do... because its selecting the
last state (WY) and not the state it should be selecting (FL)
    var selectTemplate = new Template('o.value == #{matchString}');
    selectThis = {matchString:
transport.responseXML.getElementsByTagName('state')[0].firstChild.nodeValue
};
    $$('select#ajstate option').each(function(o){
      if(selectTemplate.evaluate(selectThis)){o.selected = true;$break;}
    });

The radio button seems to be working but I need to change the data to test
it:
    var radioTemplate = new
Template('input[type=radio][name=#{selectID}][value=#{selectValue}]');
    selectThis = {selectID: 'type', selectValue:
transport.responseXML.getElementsByTagName('type')[0].firstChild.nodeValue
};
    $$(radioTemplate.evaluate(selectThis))[0].writeAttribute("checked",
"checked");



On Sat, Sep 25, 2010 at 7:59 AM, Jonathan Rosenberg <[email protected]>wrote:

>  You're passing a string constant to $$
>
>     "input[type=radio][name='type'][value=selectThis]")
>
> 'selectThis' will not be evaluated, as you seem to be expecting.  Have a
> loook at Tenplate to do what you want:
>
>     http://www.prototypejs.org/api/template
>
> --
> Jonathan Rosenberg
> Founder & Executive Director
> Tabby's Place
> http://www.tabbysplace.org
>
>   -----Original Message-----
> *From:* [email protected] [mailto:
> [email protected]] *On Behalf Of *Phil Petree
> *Sent:* Saturday, September 25, 2010 7:46 AM
> *To:* [email protected]
> *Subject:* [Proto-Scripty] Variables in $$() ?????
>
> I've hit this in two seperate places and not exactly sure why...
> (I think its the 18 hour days, 7 days a week... <g>)
>
> If "value" is hard set with '3' the following works:
> $$("input[type=radio][name='type'][value='3']")[0].writeAttribute("checked",
> "checked");
> However, if we use a variable (selectThis) and assign it "3" it does not
> work.
> var selectThis;
> selectThis = '3';
> $$("input[type=radio][name='type'][value=selectThis]")[0].writeAttribute("checked",
> "checked");
>
> Type casting doesn't work either:
> var selectThis;
> selectThis = String('3');
> $$("input[type=radio][name='type'][value=selectThis]")[0].writeAttribute("checked",
> "checked");
>
> I'm having the same problem here too (compare o.value== 'GA' and the select
> gets set to GA):
> selectThis = 'GA'
> $$('select#ajstate option').each(function(o){
>     if(o.value==selectThis){o.selected = true;$break;}
> });
>
> What am I missing here?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Prototype & script.aculo.us" group.
> To post to this group, send email to
> [email protected].
> To unsubscribe from this group, send email to
> [email protected]<prototype-scriptaculous%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/prototype-scriptaculous?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Prototype & script.aculo.us" group.
> To post to this group, send email to
> [email protected].
> To unsubscribe from this group, send email to
> [email protected]<prototype-scriptaculous%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/prototype-scriptaculous?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.

Reply via email to