The following does not work, but I’m looking for the proper syntax so that it will.
[code=php]
<html>
<head>
<title>OO SelectBox</title>
<script type=”text/javascript”>
var SelectNames = new Array
( ”, “Alley, Gasoline”, “Boop, Betty”, “Cow, Clarabel”, “Duck, Donald”, “Fudd, Elmer”);
var SelectSites = new Array
( “”, “Work”, “Home”, “Cell”, “Fax”);
function SelectList(idInfo,listInfo) {
document.write(‘<select id=”‘+idInfo+'” name=”‘+idInfo+'”>’);
for (var i=0; i<listInfo.length; i++) {
document.write(‘<option value=”‘+listInfo[i]+'” />’+listInfo[i]);
}
document.write(‘</select>’);
}
function getSelectList(idInfo,listInfo) {
fnd = -1;
for (var i=0; i<listInfo.length; i++) {
var sel = document.getElementById(idInfo);
if (sel.selectedIndex == i) { fnd = i; }
}
var str = “”;
if (fnd == -1) { str = “”; }
else { str = document.getElementById(idInfo).options[fnd].value; }
return str;
}
function Validate() {
document.getElementById(‘Requestor’).value=getSelectList(‘Requestors’,’SelectNames’).value;
document.getElementById(‘RequestorSite’).value=getSelectList(‘RequestorSites’,’SelectSites’).value;
document.getElementById(‘Substitute’).value=getSelectList(‘Substitutes’,’SelectNames’).value;
document.getElementById(‘SubstituteSite’).value=getSelectList(‘SubstituteSites’,’SelectSites’).value;
var R = document.getElementById(‘Requestor’).value;
var S = document.getElementById(‘Substitute’).value;
if (R == S) { alert(‘Can not be same person’); return false; }
else { alert(‘OK’); return true; }
}
</script>
</head>
<body>
Requestor: <input type=”hidden” id=”Requestor” value=””>
<script type=”text/javascript”>
SelectList(‘Requestors’,’SelectNames’);
</script>
Requestor Site: <input type=”hidden” id=”RequestorSite” value=””>
<script type=”text/javascript”>
SelectList(‘RequestorSites’,’SelectSites’);
</script>
Substitute: <input type=”hidden” id=”Substitute” value=””>
<script type=”text/javascript”>
SelectList(‘Substitutes’,’SelectNames’);
</script>
Substitute Site: <input type=”hidden” id=”SubstituteSite” value=””>
<script type=”text/javascript”>
SelectList(‘SubstitutesSites’,’SelectSites’);
</script>
<button onClick=”Validate()”>Check Entries</button>
</body>
</html>
The goal is to be able to use the functions to display and select from different array contents and stuff the selection into an ‘id’ element for later use.
What am I doing wrong OR is there a better way to do this? ?
Thanks for any thoughts on the concept.