Page is a not externally linkable
- Code, Content, and Presentation
-- JavaScript and AJAX
---- interactive webform


steve1978 - 9:20 am on Jan 16, 2013 (gmt 0)


Hi Dave,

Thank you.
I must admit I'm not a programmer so I hope I understand.

Anyway. I switched to another webform extension within Joomla.
I'm using Breezingforms which gives more freedom to use code.

This is the testsite:
[is.enigma-webdesign.nl ]

Here goes:

Country:
------------------------------
name:CselRegion

Action script:
function ff_CselRegion_action(element, action)
{
country = ff_getElementByName('CselCountry');
state = ff_getElementByName('CselState');

var armeniaArray = new Array('Registration', 'Basic', 'Credit');

var azerbaijanArray = new Array('Registration', 'Basic', 'Credit');

var belarusArray = new Array('Registration', 'Basic', 'Credit');

var bosniaArray = new Array('Registration', 'Basic', 'Credit');

var bulgariaArray = new Array('Registration', 'Basic', 'Credit');

var croatiaArray = new Array('Registration', 'Basic', 'Credit');

var czechrepublicArray = new Array('Registration', 'Basic', 'Credit');

var latviaArray = new Array('Registration', 'Basic', 'Credit');

if (element.value == 'none') {
// drop countries
while (country.options.length > 0)
country.options[country.options.length-1] = null;
} else {
// get the matching array
var selectedArray = eval(element.value+'Array');

// drop supernumerous option
while (selectedArray.length < country.options.length-1)
country.options[country.options.length-1] = null;

// add the new options
country.options[0] = new Option('Selecteer type rapport', 'none', true, true);
for (var i=0; i < selectedArray.length; i++)
country.options[i+1] =
new Option(selectedArray[i], selectedArray[i]);
} // if

// drop states
while (state.options.length > 0)
state.options[state.options.length-1] = null;
} // ff_CselRegion_action

Validate script:
function ff_CselRegion_validation(element, message)
{
if (element.value=='none') {
if (message=='') message = "Please select region.\n";
ff_validationFocus(element.name);
return message;
}
return '';
}


Type request:
------------------------------
name:CselCountry

Actionscript:
function ff_CselCountry_action(element, action)
{
state = ff_getElementByName('CselState');

var stateArray = new Array('immediate', 'normal', 'express', 'flash');
if (element.value=='Registration') {
// drop supernumerous option
while (stateArray.length < state.options.length-1)
state.options[state.options.length-1] = null;

// add the new options
state.options[0] = new Option('Selecteer snelheid', 'none', true, true);
for (var i=0; i < stateArray.length; i++)
state.options[i+1] = new Option(stateArray[i], stateArray[i]);
} else {
while (state.options.length > 0)
state.options[(state.options.length - 1)] = null;
} // if
} //ff_CselCountry_action


Validationscript:
function ff_CselCountry_validation(element, message)
{
if (element.value=='none' || element.value=='') {
if (message=='') message = "Please select country.\n";
ff_validationFocus(element.name);
return message;
}
return '';
}


Speed Request:
------------------------------
name: CselState

Validationscript:
function ff_CselState_validation(element, message)
{
if (ff_getElementByName('CselCountry').value=='USA')
if (element.value=='none' || element.value=='') {
if (message=='') message = "Please select state.\n";
ff_validationFocus(element.name);
return message;
}
return '';
}


As you can see it's only set to validate but I want to show the pricing.

Currently I was only to get so far showing the countries and type request but I'm not sure how to continue.
What I want is to give speed request a value to show (euro field) depenand on the choice of Country you make.

I hope this helps a bit.

Br,

Stevan


Thread source:: http://www.webmasterworld.com/javascript/4535767.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com