Hi,
My javascript function works fine in IE but not in Firefox . In a form I have a list of drop down options with the default title. the value of the dropdown options is a direct url . If the user selects an option from the dropdown and clicks on the Go button the target page will be displayed . The title doesnot have a value . so if the user doesnot select any option from the list and clicks on the Go button the title will be the default option.Since the value is null the context remains the same.
Please help me to find out a solution.
source code:
<html>
<script language=”Javascript”>
function trim(text)
{
var endIndex = text.length – 1;
var isSpace = true;
var startIndex = 0;
while (isSpace && startIndex < text.length)
{
isSpace = text.charAt(startIndex) == ‘ ‘;
if (isSpace) startIndex++;
}
isSpace = true;
while (isSpace && endIndex >= startIndex)
{
isSpace = text.charAt(endIndex) == ‘ ‘;
if (isSpace) endIndex–;
}
return text.substring(startIndex,endIndex + 1);
}
function buildTarget()
{
var ProcureTarget ;
ProcureTarget =document.form1.chooseLink.options[document.form1.chooseLink.selectedIndex].value ;
ProcureTarget =trim(ProcureTarget);
if(ProcureTarget !=”)
{
window.location.href =ProcureTarget;
}
else
{}
}
</script>
<form name=form1 method=post action=”javascript:buildTarget()”>
<select id=’SearchData’ NAME=’chooseLink’>
<option id=”1″>Popular Links</option>
<option id=”2″ value=’
Procurement Link1</option>
<option id=”3″ value=’
<option id=”4″ value=’
</select>
<input type=”button” onClick=”buildTarget()”>Click here</form>
</html>