Returning Previous field value if successor field value isn’t filled

[ad_1]

Hi Codepeople

First of all thank you for this wonderful plugin.

I’m having fieldname2, fieldname3… and so on till fieldname11. I want to retrieve data of the last fieldname. For example, if someone fills field all the way till fieldname11, then retrieved value is of fieldname11. If someone fills field all the way till fieldname10, and fieldname11 is left null or without any value, then retrieved value is of fieldname10. If someone fills field all the way till fieldname9, and fieldname10 and fieldname11 is left null or without any value, then retrieved value is of fieldname9 and so on….

(function(){

if(fieldname11 === null) return fieldname10;

if(fieldname10 === null) return fieldname9;

if(fieldname9 === null) return fieldname8;

if(fieldname8 === null) return fieldname7;

if(fieldname7 === null) return fieldname6;

if(fieldname6 === null) return fieldname5;

if(fieldname5 === null) return fieldname4;

if(fieldname4 === null) return fieldname3;

if(fieldname3 === null) return fieldname2;

if(fieldname2 === null) return fieldname1;

return ”;

})();

Also how can i hide a fieldname until previous fieldname if filled. Thank you

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer