How can I set a form select option to be selected?

26 views
Skip to first unread message

Kirsten Osa

unread,
Mar 11, 2014, 8:18:49 AM3/11/14
to support-...@googlegroups.com

$select->find('option')->removeAttr('selected');  removes all the selected attributes for the currently selected $select (<select>)  but I am unable to set selected for an option
I have tried:
$option->attr('selected',true) does not appear to work.  It adds the selected attribute on the current $option but sets it to empty string. 
I have also tried :
$option->attr('selected',"selected") but it makes no difference. 

Using DOMDocument I can do the following:
$childNode->setAttribute('selected', 'selected'); 
but I can't find an equivalent option in queryPath.

Can anyone help?

Kirsten Osa

unread,
Mar 11, 2014, 12:13:06 PM3/11/14
to support-...@googlegroups.com
Please ignore as this does work.

Reply all
Reply to author
Forward
0 new messages