pc-magas / phpquery

Automatically exported from code.google.com/p/phpquery
0 stars 0 forks source link

val() for radio button doesn't work as it expected #75

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. $myDOM->find('[input="radio"][name="test"]')->val(2);
2.
3.

What is the expected output? What do you see instead?
May check the radio button which name is "test" and which have the value
equal to "2". Instead of that it put all the radio to the value "2".

What version of the product are you using? On what operating system?
r293

Please provide any additional information below.
Don't know if it's really an issue or if we had to process value radio in
other way...

Original issue reported on code.google.com by nicolas....@gmail.com on 5 Nov 2008 at 5:28

GoogleCodeExporter commented 9 years ago
jQuery do the same, so I may be wrong...

Original comment by nicolas....@gmail.com on 5 Nov 2008 at 5:41

GoogleCodeExporter commented 9 years ago
Have replace it by in my script :

                    if (in_array($champs_element->attr('type'),array('checkbox','radio')))
                    {
                        foreach ($champs_element as $champ_element)
                        {
                            if ($champ_element->val()==$valeur)
                                $champ_element->attr('checked','checked');
                        }
                    }

Original comment by nicolas....@gmail.com on 5 Nov 2008 at 5:45

GoogleCodeExporter commented 9 years ago
Use array to check/uncheck checkboxes/radioboxes. String values changes 'value'
attribute.

Eg: pq(':radio:first').val(array(5));

Original comment by tobiasz....@gmail.com on 5 Nov 2008 at 6:10