Question Regarding Passing Values To Fields

[ad_1]

Hi! I am able to implement my forms, but it seems very inefficient currently. I am using the Dropdown for the user to select a variety of values/choices to be calculated.

Currently, I have to use switch{}/case: clauses for the choice text switch(fieldname7|r) in each field. For example:

/* Calculate using the fields that appear via the user
   dropdown selection */
(function(){
var result;
switch(fieldname7|r)
{
case 'option1': result = 0.03003/fieldname14;
break;
case 'option2': result = 0.03003/fieldname36;
break;
case 'option3': result = 0.03003/fieldname39;
break;
}
return PREC(result*1000000,1);
})()

rather than simply:

  1. Assigning values to variables based on the user dropdown choice.
  2. Calculate in desired fields using those variables (as opposed to having to use switch(), case: based on the choice text/specific fields selected via the dropdown.

i.e.,:

(function(){
var result;
/* Calculate using the variables assigned values
   by the dropdown user selection */

   result = variable1/(pow(variable2,2)*variable3);

   return PREC(result*1000000,1);
})()

Is that possible? Can the dropdown also be associated with a function or code snippet to assign values to variables, etc?

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