Welcome to the nuBuilder Forums!

Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.

Form lable on top and below text

Questions related to using nuBuilder Forte.
Post Reply
sandeepgumudelli
Posts: 41
Joined: Thu Jan 25, 2018 3:51 pm

Form lable on top and below text

Unread post by sandeepgumudelli »

Hi,

I was thinking about label and textfield, can we get label on top and below to it text ??

for referrence i have included screenshot.

Regards,
Sandeep
You do not have the required permissions to view the files attached to this post.
toms
Posts: 785
Joined: Sun Oct 14, 2018 11:25 am

Re: Form lable on top and below text

Unread post by toms »

Hi,

I created a function custFieldLabelsOnTop() to position a label on top of a field.

Usage:

Example 1: Place the labels of all fields above the input fields:

Code: Select all

	
if (nuFormType() == 'edit') {
    var f = nuSubformObject("").fields; // include all fields on your form
    custFieldLabelsOnTop(f, []);
}
Example 2: Place the labels of all fields above the input fields, but exclude some

Code: Select all

	
if (nuFormType() == 'edit') {
    var f = nuSubformObject("").fields; // include all fields of your form
    var e = ["customer_firstname", "customer_lastname"]; // but exclude these fields
    custFieldLabelsOnTop(f, e);
}
Example 3: Place the labels of some fields above the input fields

Code: Select all

	
if (nuFormType() == 'edit') {
    var f = ["customer_firstname", "customer_lastname"]; // include just these two fields
    custFieldLabelsOnTop(f, []);
}

Code: Select all

function custFieldLabelsOnTop(f, e) {

    for (var i = 0; i < f.length; i++) {
        if (jQuery.inArray(f[i], e) == -1) {

            var t = $('#' + f[i]).cssNumber("top");
            var l = $('#' + f[i]).cssNumber("left");
            $('#' + 'label_' + f[i]).css({
                'top': t - 18,
                'left': l - 15
            })
        }
    }
}

jQuery.fn.cssNumber = function(prop){
    var v = parseInt(this.css(prop),10);
    return isNaN(v) ? 0 : v;
};

sandeepgumudelli
Posts: 41
Joined: Thu Jan 25, 2018 3:51 pm

Re: Form lable on top and below text

Unread post by sandeepgumudelli »

Thank you very much tom. It is working exactly the way it shoud be. thank you very much for your support.
admin
Site Admin
Posts: 2829
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 30 times

Re: Form lable on top and below text

Unread post by admin »

.
Post Reply