On this form, we would like the sub-labels to appear above the boxes rather than below. How can I make this change?
http://www.careerprocanada.org/cpc-application-for-approval/
On this form, we would like the sub-labels to appear above the boxes rather than below. How can I make this change?
http://www.careerprocanada.org/cpc-application-for-approval/
This is not a built in option.
You can use this jQuery method and it would apply to all the description fields without having to specify each one individually.
Hi Carl,
The jQuery snippet on that page wasn't quite right (at least it didn't work for me!). I've modified it slightly as follows, this isn't a fully tested method however.
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery('.ginput_container label').each(function(i,e){
fielddesc = jQuery('<div>').append(jQuery(e).clone()).remove().html();
jQuery(e).siblings('.ginput_container input').before(fielddesc); //moves sub label above input fields
jQuery(e).siblings('.ginput_container select').before(fielddesc); //moves sub label above select fields (e.g. country drop-down)
jQuery(e).remove();
});
});
</script>
Thanks for sharing Joff. :)
I edited this a little for my form, since the code above was making my radio labels wonky. This code is the same as above except it selects text inputs specifically while making an exception for radio buttons. Hope someone finds it useful!
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery('.ginput_container label').each(function(i,e){
fielddesc = jQuery('<div>').append(jQuery(e).clone()).remove().html();
jQuery(e).siblings('.ginput_container input:text').before(fielddesc); //moves sub label above input fields
jQuery(e).siblings('.ginput_container select').before(fielddesc); //moves sub label above select fields (e.g. country drop-down)
jQuery(e).siblings('.ginput_container .gfield_radio input').after(fielddesc); //keep label above radio buttons
jQuery(e).remove();
});
});
</script>
Thanks cjmox. I am sure someone will.
You missed a line... Without it, checkbox fields don't work. Here's the correct code.
[js]
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery('.ginput_container label').each(function(i,e){
fielddesc = jQuery('<div>').append(jQuery(e).clone()).remove().html();
jQuery(e).siblings('.ginput_container input:text').before(fielddesc); //moves sub label above input fields
jQuery(e).siblings('.ginput_container select').before(fielddesc); //moves sub label above select fields (e.g. country drop-down)
jQuery(e).siblings('.ginput_container .gfield_radio input').after(fielddesc); //keep label above radio buttons
jQuery(e).siblings('.ginput_container .gfield_checkbox input').after(fielddesc); //keep label above checkboxes
jQuery(e).remove();
});
});
</script>
Thanks for the update DrDave.
Actually, this isn't right either.. It doesn't move the email field descriptions...
Unfortuantely, I'm sick, and my coding ability is about 0 today.
I tried adding this:
jQuery(e).siblings('.ginput_container input:email').before(fielddesc);
But, it doesn't work..
Anyone who's not sick care to fix my mistake? Then, it should actually work correctly :)
Solution:
jQuery('.ginput_container label').each(function(i,e){
fielddesc = jQuery('<div>').append(jQuery(e).clone()).remove().html();
jQuery(e).siblings('.ginput_container input[type=email]').before(fielddesc);
jQuery(e).siblings('.ginput_container input:text').before(fielddesc); //moves sub label above input fields
jQuery(e).siblings('.ginput_container select').before(fielddesc); //moves sub label above select fields (e.g. country drop-down)
jQuery(e).siblings('.ginput_container .gfield_radio input').after(fielddesc); //keep label above radio buttons
jQuery(e).siblings('.ginput_container .gfield_checkbox input').after(fielddesc);
jQuery(e).remove();
});
I posted something similar earlier this evening, here:
http://www.gravityhelp.com/forums/topic/address-labels-below-fields#post-176132
Is this working for you now?
Chris, your pastebin is the old version...
jQuery('.ginput_container label').each(function(i,e){
fielddesc = jQuery('<div>').append(jQuery(e).clone()).remove().html();
jQuery(e).siblings('.ginput_container input[type=email]').before(fielddesc);
jQuery(e).siblings('.ginput_container input:text').before(fielddesc); //moves sub label above input fields
jQuery(e).siblings('.ginput_container select').before(fielddesc); //moves sub label above select fields (e.g. country drop-down)
jQuery(e).siblings('.ginput_container .gfield_radio input').after(fielddesc); //keep label above radio buttons
jQuery(e).siblings('.ginput_container .gfield_checkbox input').after(fielddesc);
jQuery(e).remove();
});
This one above works ^^^^ the one you have on the pastebin doesn't do emails properly...
(and, pastebin: http://pastebin.com/wbrrLBkx )
Thanks for the updated code. http://pastebin.com/CfFeP4Ux
Here's an update by Ross McKay:
The code there acts upon all fields, then undoes its actions for radio buttons and checkboxes. Better to just not act on those. Here's a snippet that only adds the script to pages with a Gravity Forms form, and doesn't act on radio buttons or checkboxes.