Code: Select all
if(document.getElementById("fieldname1").value!=""){
document.getElementById("fieldname2").readOnly = true;
}
Thank you.
Weoi
Code: Select all
if(document.getElementById("fieldname1").value!=""){
document.getElementById("fieldname2").readOnly = true;
}
Code: Select all
$j(function(){
// set "disabled" fields
var fieldlist='#type, #description, #unit, #buy_price, #sell_price, #suggested_price';
$j(fieldlist).prop('readonly', true);
$j(fieldlist).prop('tabIndex', -1);
$j(fieldlist).prop('style', 'cursor: not-allowed; background-color: #EEE;');
$j(fieldlist).mousedown(function(){return false;});
});
thank you very much for answered and solve my question grimblefritz its save tons of my timegrimblefritz wrote:I recommend against using disabled fields, unless you don't want to retain the data in those fields.
See this thread: http://forums.appgini.com/phpbb/viewtop ... f=8&t=2159
The method I use, using jquery, is included in that thread. It gives me all the benefits of disabled over readonly, without the data loss risk of disabled.
That thread also includes the jquery for disabling a rich text field.
One advantage of jquery is it can process multiple fields. The following snippet sets 6 fields. It could just as easily set 1 or 100.
Code: Select all
$j(function(){ // set "disabled" fields var fieldlist='#type, #description, #unit, #buy_price, #sell_price, #suggested_price'; $j(fieldlist).prop('readonly', true); $j(fieldlist).prop('tabIndex', -1); $j(fieldlist).prop('style', 'cursor: not-allowed; background-color: #EEE;'); $j(fieldlist).mousedown(function(){return false;}); });
Just running appgini with disabled javascript and it seems appgini still workinggrimblefritz wrote:AppGini won't work if javascript is disabled, so there's no additional risk in using javascript in hooks. Besides, I thought the phobias about javascript were dispelled long ago. It's been years since I encountered anyone running with it disabled.
Code: Select all
function setFieldAsLabel(array_field_selector){
var arrayLength = array_field_selector.length;
for (var i = 0; i < arrayLength; i++) {
var $field = $j('#'+array_field_selector[i]);
if ($j('#'+array_field_selector[i]+'-container').length != 0) {
$j('#'+array_field_selector[i]+'-container').select2('enable', false);
$j('#'+array_field_selector[i]+'-container').parent().find('button').hide();
} else {
$j('#'+array_field_selector[i]).prop('readonly', true);
$j('#'+array_field_selector[i]).prop('tabIndex', -1);
$j('#'+array_field_selector[i]).prop('style', 'cursor: not-allowed; background-color: #EEE;');
$j('#'+array_field_selector[i]).mousedown(function(){return false;});
}
}
}
Code: Select all
var myfields = ["field1","field2","field3"];
setFieldAsLabel(myfields);
Works great, thank you!globaldrip8 wrote: ↑2016-08-27 16:55thank you very much for answered and solve my question grimblefritz its save tons of my timegrimblefritz wrote:I recommend against using disabled fields, unless you don't want to retain the data in those fields.
See this thread: http://forums.appgini.com/phpbb/viewtop ... f=8&t=2159
The method I use, using jquery, is included in that thread. It gives me all the benefits of disabled over readonly, without the data loss risk of disabled.
That thread also includes the jquery for disabling a rich text field.
One advantage of jquery is it can process multiple fields. The following snippet sets 6 fields. It could just as easily set 1 or 100.
Code: Select all
$j(function(){ // set "disabled" fields var fieldlist='#type, #description, #unit, #buy_price, #sell_price, #suggested_price'; $j(fieldlist).prop('readonly', true); $j(fieldlist).prop('tabIndex', -1); $j(fieldlist).prop('style', 'cursor: not-allowed; background-color: #EEE;'); $j(fieldlist).mousedown(function(){return false;}); });