This topic is locked
[SOLVED]

 Read-Only And Change Value Of Dropdown

2/4/2013 4:19:21 PM
PHPRunner General questions
R
rustler45 author

I have a dropdown "status" that has 5 selections:
Submitted

Pending

Approved

Rejected

Paid
I want to be able to set the value of the dropdown on the Edit page based on the user that is logged in. I have code that does this well, but now I need to make that dropdown a read-only also. I am using this to change the dropdown value to "Submitted" whenever the users "1" login in.
I have this as a snippet:
echo "<script>
window.username = '" . $_SESSION["UserID"]. "';
window.group = '" . $_SESSION["GroupID"]. "';
</script>";
and this as javascript onload event:
if (group!='1')
{
var ctrl = Runner.getControl(pageid, 'status');
ctrl.setValue('Submitted');

}
I have been trying to find it in the manual, is it possible to control the value of the dropdown and the read-only at the same time?
I am using PHPRunner 6.1 build 12662
thanks,

Rusty

C
cgphp 2/4/2013
R
rustler45 author 2/5/2013

I read the section on makeReadonly and have used it on other fields, but after re-reading the section I still dont know how to make the field readonly and set the value of the dropdown at the same time. I cant set it as readonly in the visual editor because it needs to be editable for the admin user.

C
cgphp 2/5/2013

If "Submitted" is the option value of the dropdown, use this code:

if (group != '1')

{

var ctrl = Runner.getControl(pageid, 'status');

ctrl.getDispElem().attr('disabled','disabled').val('Submitted');

}


If "Submitted" is the text value of the dropdown, use this code:

if (group != '1')

{

var ctrl = Runner.getControl(pageid, 'status');

ctrl.getDispElem().attr('disabled','disabled').find("option:contains('Submitted')").attr('selected','selected');

}
R
rustler45 author 2/5/2013

Cristian, that worked great. thanks!