Page 1 of 1
Running length of text field
Posted: Thu May 01, 2014 3:08 pm
by Tinka
Hi
I tried this solution in this post:
http://forums.nubuilder.cloud/viewtopic.p ... ers#p12550.
It does not work for me. Would you please help?
What has the html object to be? I put an input box read-only:
Code: Select all
<input readonly type=text name=bases
size=3 value="0">
The Javascript function is on the Edit form's Javascript tab. I tried both the html-object name or object id form the zzzsys_object table.
Code: Select all
function nuLoadEdit() {
$('#531dcb7d9bf9567').keyup(function () {
var max = 30;
var col = 'grey';
var len = $(this).val().length;
if (len >= max) {var col = 'red';}
$('#bases')
.text(len)
.css('color', col);
});
}
Tinka
Re: Running length of text field
Posted: Sat May 03, 2014 9:16 pm
by massiws
Tinka,
your HTML object must have id="bases", so jQuery can select it.
Max
Re: Running length of text field
Posted: Fri May 09, 2014 9:49 am
by Tinka
Max,
thank you for your reply. My html object has the field name "bases", but do you mean the object id in the zzzsys_object table?
Is the syntax in the Javascript ok?
Tinka
Re: Running length of text field
Posted: Fri May 09, 2014 10:00 am
by Tinka
Got it working! You can close the topic.
I changed the object name of the object with keyup from the id in the system table to the field name!
Code: Select all
function nuLoadEdit() {
$('#prim_sekvens').keyup(function () {
var max = 30;
var col = 'grey';
var len = $(this).val().length;
if (len >= max) {var col = 'red';}
$('#bases')
.text(len)
.css('color', col);
});
}
Tinka
Re: Running length of text field
Posted: Fri May 09, 2014 10:41 am
by Tinka
Any idea how to save the value of the running text length to the field afterwards (on After Save Custom Code)?
Re: Running length of text field
Posted: Sun Jun 01, 2014 5:30 pm
by massiws
Tinka, do you want to store the length value in database?
If so, you should create a new field in your table and configure a text object on your form to map this field; alternatively, configure your "
bases" field to map the new created DB field.
Then add a new line in your function to store the length value in DB field:
Code: Select all
function nuLoadEdit() {
$('#prim_sekvens').keyup(function () {
var max = 30;
var col = 'grey';
var len = $(this).val().length;
if (len >= max) {var col = 'red';}
$('#bases')
.text(len)
.css('color', col);
});
$('#my-db-field-name').val(len);
}
Max
Re: Running length of text field
Posted: Tue Jun 03, 2014 11:42 am
by Tinka
Thank you, I had figured it out.
Re: Running length of text field
Posted: Tue Jun 03, 2014 9:33 pm
by massiws
.