This topic is locked
[SOLVED]

 enable/disable fields

12/28/2010 5:22:56 PM
PHPRunner General questions
M
maru1958 author

Hi,

how do I enable/disable a field when adding or edditing a record depending on a checked/unchecked checkbox?
Thanks,

Maru

romaldus 12/29/2010



Hi,

how do I enable/disable a field when adding or edditing a record depending on a checked/unchecked checkbox?
Thanks,

Maru


Use PHPRUNNER javascript API to do this. Please read the PHPRUNNER manual (programming topics) to understand how it works.
In this example i use DROPDOWN instead of CHECKBOXES.

I have two DROPDOWN fields : PAYMENT TYPE and BANK

There are Two fields in PAYMENT_TYPE field:



PAYMENT_ID
....DESCRIPTION

1.......................BANK TRANSFER

2.......................COD
the second dropdown (BANK) is listed of bank names
when i choose BANK TRANSFER on Payment type dropdown, then the second dropdown enabled. but when i choose COD, then the second dropdown field disabled:
I use this javascript code in my JavaScript Onload Event ini my add/edit page :



var ctrlPaymentType = Runner.getControl(pageid, 'PAYMENT_ID');

var ctrlBank = Runner.getControl(pageid, 'BANK_NAME');
ctrlctrlPaymentType.on('change', function(e)

{

if (this.getValue() == '1')

{ctrlBank.setEnabled();}

else

{ctrlBank.setDisabled();}

});


The value '1' above is the link field value of the PAYMENT_ID dropdown.

C
chingupt 1/3/2011

Gr8. Thanks. But this for the Form Fields. In php runner how do we control the labels.
I am trying to show/hide some fields depending on the drop down selection. I have been able to hide/show the fields, but could not do the same for the labels corresponding to the fields.
How do you gain control of the labels? With only the labels showing up, it looks pretty bad.
Regards

Sachin

M
maru1958 author 1/5/2011

Thanks for your reply!
I tried your example and adapted it to my checkbox requirement; both worked fine with Firefox, Safari, Chrome and Opera but none did with IE8. Any ideas?
Maru

romaldus 1/5/2011



Thanks for your reply!
I tried your example and adapted it to my checkbox requirement; both worked fine with Firefox, Safari, Chrome and Opera but none did with IE8. Any ideas?
Maru


Please check your IE security settings...

D
danaci 1/5/2011

warning.

fieldname and function name different <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=55407&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />
var ctrlPaymentType = Runner.getControl(pageid, 'PAYMENT_ID');

var ctrlBank = Runner.getControl(pageid, 'BANK_NAME');
ctrlctrlPaymentType.on('change', function(e)

{

});
var ctrlPaymentType

ctrlctrlPaymentType.on('change', function(e)

double ctrl <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=55407&image=2&table=forumreplies' class='bbc_emoticon' alt=':)' />

romaldus 1/5/2011



warning.

fieldname and function name different <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=55415&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />
var ctrlPaymentType = Runner.getControl(pageid, 'PAYMENT_ID');

var ctrlBank = Runner.getControl(pageid, 'BANK_NAME');
ctrlctrlPaymentType.on('change', function(e)

{

});
var ctrlPaymentType

ctrlctrlPaymentType.on('change', function(e)

double ctrl <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=55415&image=2&table=forumreplies' class='bbc_emoticon' alt=':)' />


it was a mistake <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=55415&image=3&table=forumreplies' class='bbc_emoticon' alt=':)' />
should be :

ctrlPaymentType.on('change', function(e)


<img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=55415&image=4&table=forumreplies' class='bbc_emoticon' alt=':rolleyes:' />:rolleyes:<img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=55415&image=5&table=forumreplies' class='bbc_emoticon' alt=':rolleyes:' />:rolleyes:<img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=55415&image=6&table=forumreplies' class='bbc_emoticon' alt=':rolleyes:' />:rolleyes:<img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=55415&image=7&table=forumreplies' class='bbc_emoticon' alt=':rolleyes:' />:rolleyes:<img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=55415&image=8&table=forumreplies' class='bbc_emoticon' alt=':rolleyes:' />:rolleyes:<img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=55415&image=9&table=forumreplies' class='bbc_emoticon' alt=':rolleyes:' />