PDA

View Full Version : Dropdown value's



stehl
14-Sep-2010, 01:47 AM
what would the coding in the computation module be to determine the value or selected index of a drop down menu... I tried everything I know.

I am trying to determine if a text field is empty, if it is a variable is the value of the dropdown. and vice versa.


The actual situation is I have a state drop down, and a province field... and only can have one spot in the database without messing up the structure. I am trying to determine if either the state drop down is empty or the province field is empty. The one that is not empty is written to the variable that is written in the shipping address section of the database.

russellr
14-Sep-2010, 10:15 AM
Hi,

The value can be tested just like any other field.

It sounds like a simple problem of not having your default selection as empty.

For example,


<option>Please select a state</option>
...
is *not* correct. This will result in the field always having a value.

Instead, you need this:


<option value="">Please select a state</option>
...
If that's not the problem, please provide the URL to your form so I can take a look.

stehl
15-Sep-2010, 01:43 AM
Here is what I have as the If statement:


if (s_state == 'none')
{
s_stateProv2 = s_stateProv;
}

if (s_stateProv != '')
{
s_stateProv2 = s_state;
}


I have the variables imported and exporting fine by placing it on the next page, it just leaves some fields blank like it wont write.


here is the Html:



<select name="s_state" id="s_state"/>
<option value="none">Other:</option>
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>
<option value="AR">Arkansas</option>
<option value="CA">California</option>.........................................
continues on



Im going to copy what is written in the database soon as I run a test order.

russellr
15-Sep-2010, 03:15 AM
Hi,

That all looks fine.

But, what is the actual logic you want?

Is it:


If state and province are empty, then error.
If state is set, store that.
If province is set, store that.

OK, but what if both state and province are set?

Here's some logic that will achieve the above:


if (s_state != 'none')
{
s_stateProv2 = s_state;
}
elseif (s_stateProv != '')
{
s_stateProv2 = s_stateProv;
}
else
{
FMUserError('You must provide state or province');
}

/* s_stateProv2 is written to the database */

michaelhilliker25
02-Jan-2012, 11:02 PM
Hi everyone.
This is Michael. I amvery thankfull to you who share this information about the dropdown values, because i need this information very much Thankyou for sharing.

Thankyou