Hi there,
I am trying to use a value from the select field to replace text within a strong tage;
<strong id="selected_country">Country Will appear here</strong>
So far the script anounces the selected country using alert. Here is the scrupt so far:
function getCountry()
{
// Validate that the browser knows getElementById
if(!document.getElementById ) return;
// Get the "pages" select box
var pagesObj = document.getElementById("distributor");
// Validate that the object exists
if(!pagesObj ) return;
// Get the options array. This works for both
// single select and multi select boxes
if( typeof(pagesObj.options) == "undefined" || pagesObj.options == null ) return;
var o = pagesObj.options;
// Get the selected options into an array
var s = new Array();
for( var i = 0; i < o.length; i++ )
{
if( o[i].selected )
{
s[s.length] = o[i].value;
}
}
// s now contains an array of the selected values.
// If nothing was selected, the array length is 0
if( s.length == 0 )
{
alert("You must select a value.");
}
else
{
for( var i = 0; i < s.length; i++ )
{
// Do whatever you want with the values here
var selectedCountry = s[i];
//HERE IS WHERE I THINK IT GOES
alert(selectedCountry)
}
}
}
}
Any help would be a bonus.
Thanks
Darren