hello all I am trying to check if a user picked out a value from a listbox in a form. I iniatially fill up the list box with all values but when showed in the form the first value is empty. So when the user click the SEARCH button to submit the for I call the Search() function below: function Search() { var Scope = document.all.Scope.value; alert(typeof(Component)); //returns string alert(Component.value); //returns undefined if(Component.value == undefined) { alert("Component value is required for Search!"); } else { alert("Proceed with Search."); } } Even though I pick a value in the listbox it still returns undefined. Why? Thank you
There you go: <SELECT id=Scope name=Scope ovalue=""> <OPTION value="" selected></OPTION> <OPTION value=1>Global</OPTION> <OPTION value=2>Branch</OPTION> <OPTION value=3>Group</OPTION> <OPTION value=4>Role</OPTION> <OPTION value=5>Machine</OPTION> </SELECT> </TD> Thank you
I cannot see where do you call the function. Can you explain in details what you want? I don't understand.
sorry, this might help: <input type="button" id="cmdSearch" class="btn" value="Search" onclick="Search();"/> <script language="javascript"> var strRemoteFunctionsPath = "CustomXMLAjax.cfm"; function Search() { var Scope = document.all.Scope.value; var Action = document.all.Action.value; var Component = document.all.Component.value; if(window.dialogArguments) { addItemValues=window.dialogArguments.addItemValues; } if(Component.value == undefined) { alert("Component value is required for Search!"); } else { DWREngine._execute(strRemoteFunctionsPath, null, 'Search', Scope, Action, Component, Search_Callback); } } function Search_Callback(data) { document.all.SearchResultsCell.innerHTML=data; }