frappe.ui.form.on("Draft", {
lots: function(frm){
// code
set_value_message(frm);
},
action: function(frm){
// code
set_value_message(frm);
}
});
var set_value_message = function(frm){
var message = (frm.doc.action || "") + " " + (frm.doc.lots || "");
frm.set_value("your_message", message);
}
Every time you leave textbox lots and action, it will set value to your_message.
nikzz
August 2, 2018, 6:15am
22
Thanks, Got some hints from this one
nikzz
August 2, 2018, 6:38am
23
I am trying to put an if condition in a html field and then print the message as accordingly to my message box.
Here’s the image of my field:
Here’s the code
var option_val=[];
frappe.ui.from.on("Draft",{
option_value: function(frm){
if (document.getElementById('call').checked) {
option_val="ABC";
} else {
option_val="DEF";
}
set_value_message(frm);
}
});
var set_value_message = function(frm){
var message = ( option_val || "")
frm.set_value("your_message", message);
}
I am unable to reach to the value of radio button’s value of html field. What am I doing wrong ?
nikzz
August 2, 2018, 7:58am
24
even on
option_value: funtion(frm) {
alert('q');
}
Its no getting inside the option_value field. Any help will be appreciated
I can’t get radio button worked. Once I clicked it’s checked and unchecked automatically.
Why don’t you use Select Option instead of radio button?
nikzz
August 3, 2018, 7:01am
26
Any way to do it via interpolation. Like if i type abc if field 1 then same automatically get typed in field 2 (without switching tab or anywhere else, ie remaining on same field) ??
I think no builtin frappe method for that. Use jquery keyup to accomplish what you want.
nikzz
August 3, 2018, 7:22am
28
Through Interpolation in custom script ?
yes jQuery is available in frappe. you can run any jQuery method inside custom script
nikzz
August 3, 2018, 8:08am
30
trying something like this to test:
$(document).ready(function () {
$(cur_frm.doc.name1).on('change', function (e) {
$(cur_frm.doc.name_2).val($(cur_frm.doc.name1).val());
});
});
Trying to get content in name 2 field as i type in name 1.
Any help ?
change method does not fire as you are typing.
Try,
https://api.jquery.com/keyup/
nikzz
August 3, 2018, 11:33am
32
$(document).ready(function () {
$(cur_frm.doc.name1).keypress(function() {
$(cur_frm.doc.name_2).val($(cur_frm.doc.name1).val());
});
});
NO Progress. Need Some serious help
nikzz
August 3, 2018, 12:02pm
33
$(`cur_frm.doc.name1`).keypress(function() {
console.log( "Handler for .keypress() called." );
});
trying just a single field. Any hint for what should be there in place of cur_frm.doc.name1 (name1 is the field of name)
try something like below,
$(‘[data-fieldname=“name1”]’).keypress(function() {
console.log( “Handler for .keypress() called.” );
});
nikzz
August 3, 2018, 1:29pm
35
yeah already figured that one but i’m having difficulty in writing content to other field at same time.
nikzz
August 6, 2018, 4:26am
36
Any help ??
$(`[data-fieldname='name1']`).keypress(function() {
var z= $(`[data-fieldname='name_2']`).val(this.val);
console.log(z);