text field use if else

  • Posts: 2645
  • Karma: 92
  • Thank you received: 354

mihaela replied the topic: text field use if else

Hi,

we're working on your form. It has some JavaScript errors that we're fixing. You can expect your form back on Thursday.

Regards,

Mihaela
#214800
The following user(s) said Thank You: aminweb
  • aminweb
  • Topic Author
  • Offline
  • Expert Boarder
  • Expert Boarder
  • Posts: 91
  • Thank you received: 0

aminweb replied the topic: text field use if else

Thank you so much
So I'm waiting for your answer
#214801
  • aminweb
  • Topic Author
  • Offline
  • Expert Boarder
  • Expert Boarder
  • Posts: 91
  • Thank you received: 0

aminweb replied the topic: text field use if else

Hi to beautiful Thursday ;)
Mr. Mihaela, have you checked?
I'm waiting for your server solution.
#214865
  • Posts: 2645
  • Karma: 92
  • Thank you received: 354

mihaela replied the topic: text field use if else

Hello,

Sorry for waiting.

We edited your form to do what you wanted and it is ready for use now. I'm sending it as an attachment. Also, we added missing fields to your form.

You can see the code bellow needed for your calculations if you go to Advanced > More options > Scripts. Initialization Script Type should be set to Custom and the code is there.
function ff_eghamat_init()
{
    setInterval(showage,500);
    setInterval(calc, 500);

} // ff_calc_age_init

function calc() {
    var total = 0;
    var paygov;
    
   for(var i = 1; i < 4; i++) {
        var paygov = jQuery('[name="ff_nm_paygov'+i+'[]"]:checked').val();
    
        if(  ff_getElementByName('calculated_age'+i).value < 18 && jQuery('[name="ff_nm_eghamattime'+i+'[]"]:checked').val() == 'oneyear') {
            ff_getElementByName('bimetottal'+i).value =  Number(paygov) + 40;
            }
        else if( ff_getElementByName('calculated_age'+i).value < 18 && jQuery('[name="ff_nm_eghamattime'+i+'[]"]:checked').val() == 'twoyear') {
            ff_getElementByName('bimetottal'+i).value = Number(paygov) + 70;
            }
        else if(  ff_getElementByName('calculated_age'+i).value > 18 && jQuery('[name="ff_nm_eghamattime'+i+'[]"]:checked').val() == 'oneyear') {
            ff_getElementByName('bimetottal'+i).value = Number(paygov) + 80;
            }
        else if(  ff_getElementByName('calculated_age'+i).value > 18 && jQuery('[name="ff_nm_eghamattime'+i+'[]"]:checked').val() == 'twoyear') {
            ff_getElementByName('bimetottal'+i).value = Number(paygov) + 140;
        }            
    }
     //Calc for Total
     total = Number(ff_getElementByName('bimetottal1').value) + Number(ff_getElementByName('bimetottal2').value) + Number(ff_getElementByName('bimetottal3').value) 
     + Number(ff_getElementByName('bimetottal4').value);
     ff_getElementByName('pricetottal').value = Number(total);

}

function showage(){
    var one_year=1000*60*60*24*365;
    var date1 = new Date();
    for (var n = 1; n < 4; n++) {
        var  dob= ff_getElementByName('birthday'+ n).value;

        var tmp=dob.split("/");
        var date2=new Date(tmp[2],tmp[1]-1,tmp[0]);

        var pattern = /[0-3][0-9]\/(0|1)[0-9]\/(19|20)[0-9]{2}/; //Regex to validate date format (dd/mm/yyyy)
        if (pattern.test(dob)) {
            var y1 = date1.getTime(); //getting current year
            var y2 = date2.getTime(); //getting dob year
            var diff=Math.floor((y1-y2)/one_year);
            
            ff_getElementByName('calculated_age'+ n).value=diff;
        }
    }
} // showage END

If you have more questions, feel free to ask.

Regards,

Mihaela
#214933
Attachments:
The following user(s) said Thank You: aminweb
Moderators: ForumSupporttomeperica
Time to create page: 0.069 seconds

New Icon Packs Category!

Crosstec is now offering icon packs.

If you are a paying subscriber, icon packs are automatically added to your account.

Check out our icon packs page!

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the team!

Summer Sale!

50% discount on all of our extension subscription plans, templates and icon packs!

Get Your Subscription Here

News and Updates

Get informed about new downloads, updates and more in our News and Updates newsletter.

All Extensions Subscription

Get 1 year access to all of our current and future products and 1 year of professional support -- 99 for just 49! (Summer Sale)

No support per domain or website installation limits! Includes all of our current and future Joomla!® extensions, Joomla!® templates for the duration of your membership. This means, by purchasing an All Extensions Subscription you'll have it all covered!

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the team!

Community Reward

Help us to create new extensions and plugins! With only $5 you help us a lot and get unlimited download access to all of our products, professional support and even more. Get your reward now!

Read More Here