Ok...
This is for an input box, to create a new 'user id' i'll say, for the system. The user id must consist of a letter from a predefined (in a table in the db) agency code, and four numbers.
My problem is that the code i have so far can do everything but select the agency code letter from only the ones existing in the data base already.
This is the input box in a php file that is viewed when the page is accessed:
User ID: <input name="divcode" onChange="isValidNEWUI(this); value="start">
This is a seperate page, the validation code in java script which is found in an include file:
function isValidNEWUI(field)
var userIDPattern = /([A-V]{1})(\d{4})/;
var matchArray = field.value.match(userIDPattern);
if(matchArray == null) {
alert("Not in valid format!);
field.focus();
field.select();
return false;
}
checkdivcode()
}
Now, this is a query i can run, to get all the information from the db about the user ID first letter's available, but i do not want a select box, and i don't know how to make the javascript test to see if the pattern matches one of these letters instead of using the A-V.
$idLetter = mysql_query("SELECT code_id, ed_name FROM codebook WHERE code_type = 'DI' ORDER BY ed_name' ");
while($divLetters=mysql_fetch_array($divLetter)) {
echo"<option value=\"$divLetters[0]\">$divLetters[1]\n";
}
Can someone help? pretty please???