質問

This is my first post here. I'm stucked on a project of moodle customed module. I've a module where I have 2 select box on the module creation form. First select options loaded correctly but the second select option loads but selected option dosent appear on the box. I checked source code created by yui3 for the 2nd option is:

<select>
<option id="">Choose...</option>
<option id="{some id}" selected>{value}</option>
</select>

In mozilla it works fine... but when i tried it on chrome it always shows the text choose...

selected option of 1st select is shown as selected="selected". Thats the only difference I found on html.

YAHOO.util.Dom.get('id_pwid').options[i+1] = new Option(pwTitle, pwId, (pwId == pwid_sel));

this is how it loads the 2nd options.

Please help me out from this problem.

[[This 2 select options load from an oracle database via soap request]]

Thank you

役に立ちましたか?

解決

You are not setting the selected parameter.

Option has the following 4 parameters, you are not setting the last one

new Option([text], [value], [defaultSelected], [selected])

See a working example here http://jsfiddle.net/casperskovgaard/KggNu/

Your code should be changed to some thing like this:

YAHOO.util.Dom.get('id_pwid').options[i+1] = new Option(pwTitle, pwId, false, (pwId == pwid_sel));

他のヒント

Not sure if it helps, but here's an example of using Ajax with Moodle Forms http://docs.moodle.org/dev/User:Mark_Johnson/Mforms_and_AJAX

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top