wolferhua / phpquery

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

val(value) doesnt work with set of elementS #83

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. using val(value) method on a set of elements
2.
3.

What is the expected output? What do you see instead?
it set the value attribute of the first elemnt in the set but not to the
other. It should set the value attribute of each element in the set.

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

Please provide any additional information below.

Original issue reported on code.google.com by nicolas....@gmail.com on 30 Nov 2008 at 11:06

GoogleCodeExporter commented 9 years ago
Perhaps that's the same problem that issue 82.
And so perhaps other method should be fix too ?

Original comment by nicolas....@gmail.com on 1 Dec 2008 at 8:28

GoogleCodeExporter commented 9 years ago
Can't reproduce it. Need more information. Code below works as expected:
$doc = phpQuery::newDocument('<input name="test1" value="old1"/> <input 
name="test2"
value="old2"/>');
print $doc['input']->val('new');

Original comment by tobiasz....@gmail.com on 1 Dec 2008 at 8:41

GoogleCodeExporter commented 9 years ago
Should make some test more so.
Have test it using the selector "[name=toto]" and a DOM like <dom><select
name="toto"><option></option><option value="1">1</option></select><div><input
type="hidden" name="toto"/></div></dom>.
And so doing <php>$mySetOfElements = $myDOM->find('[name="toto"]');</php>, and 
so
<php>$mySetOfElements->length();</php> give me "2" but
<php>$mySetOfElements->val(1);</php> doesn't set the value of the input element.

Original comment by nicolas....@gmail.com on 1 Dec 2008 at 8:57

GoogleCodeExporter commented 9 years ago
note that i've replaced <php>$mySetOfElements->val(1);</php> by <php>foreach
($mySetOfElements as $element) pQ($element)->val(1);</php> and it works.

Original comment by nicolas....@gmail.com on 1 Dec 2008 at 9:01

GoogleCodeExporter commented 9 years ago
Fixed in r311. Problem existed when matched elements contained at least one 
select.

Original comment by tobiasz....@gmail.com on 1 Dec 2008 at 9:21

GoogleCodeExporter commented 9 years ago
Thanks tobiaz !

Original comment by nicolas....@gmail.com on 1 Dec 2008 at 9:25

GoogleCodeExporter commented 9 years ago
tobiaS :x

Original comment by nicolas....@gmail.com on 1 Dec 2008 at 9:26