Welcome to the nuBuilder Forums!
Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.
ruiascensao
Posts: 177 Joined: Tue Nov 15, 2011 2:24 pm
Unread post
by ruiascensao » Tue Jun 12, 2012 4:57 pm
Hi,
I have a form that displays data from the database. In this form I have a field that is a dropdown list:
Code: Select all
<div id='subform_grade_udetails0026l332t598' style='position:absolute;top:598px;left:332px'>
<select name="subform_grade_udetails0026udetails_cos" id="subform_grade_udetails0026udetails_cos" class="objects" style="width:80px;" onchange="untick('subform_grade_udetails0026', this);uDB(this);calcStatus();" onfocus="nuSetRow('subform_grade_udetails0026');" >
<option value=''></option>
<option value='Failed'>Failed</option>
<option value='Passed'>Passed</option>
</select>
</div>
With JavaScript I'm trying to assign a value to this field by using:
Code: Select all
document.getElementById('subform_grade_udetails0026udetails_cos').value= 'Failed';
But it doesn't work.
Is this the correct way to assign a value to a dropdown field?
Thank you!
Rui
BR
Rui
ruiascensao
Posts: 177 Joined: Tue Nov 15, 2011 2:24 pm
Unread post
by ruiascensao » Wed Jun 13, 2012 11:02 am
Hi Steven,
I have tried:
Code: Select all
setSelectedIndex(document.getElementById(PRE+'udetails_func'),"Failed");
function setSelectedIndex(s, v) {
for ( var i = 0; i < s.options.length; i++ ) {
if ( s.options[i].text == v ) {
s.options[i].selected = true;
return;
}
}
}
I seen that the dropdown box is filled with "Failed". When I save fields are getting blank.
In the code I see that the "Failed" option is not "Selected" and I don't understand why.
Could you please help me with this?
Thank You!
Rui
BR
Rui
admin
Site Admin
Posts: 2824 Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 29 times
Unread post
by admin » Thu Jun 14, 2012 1:48 am
rui,
Its not a nuBuilder question, its a JavaScript question.
You need to either join a JavaScript forum or pay for someone to teach you or do it for you.
Steven
massiws
Posts: 503 Joined: Thu May 24, 2012 2:08 am
Location: Milan, Italy
Contact:
Unread post
by massiws » Wed Jul 11, 2012 11:32 am
rui,
I hope you've already fixed!
ruiascensao wrote:
Code: Select all
document.getElementById('subform_grade_udetails0026udetails_cos').value= 'Failed';
Is this the correct way to assign a value to a dropdown field?
Maybe you can try to set the ID value instead of 'Failded' value.
Hope this helps.