OK LCD, don't be confused!
I'll try to explain you what happens here.
big shot somebody,01235284563547
client someone,12345678901234
client someone else,00123456789012
das client,00123456789012
das other client,45678901237123
the lemmings,25484756241544
Left part of each pair is a value of OPTION items of your <select>. Rigth part - the numbers you have to associate with the left part.
My suggestion was to create an array of numbers:
numbArray = new Array(,01235284563547
, 00123456789012, 00123456789012, ..... );
"numbArray" is just a name of JavaScript variable and of course you can change it.
The main condition is that all numbers you enter are in the same order as their names from left.
OPTOIN items are also the elements of an array (another one, it is created automatically), and every element has it's position number named index.
So all we have to do is to find the number that is associated with name. It can be done by comparison of their indexes.
This is done here by creating a function:
function FindNumber() {
for (i=0; i <= numbArray.length; i++)
{
if ( numbArray = yourForm.Project.options.selectedIndex )
yourForm.PONumber.value = numbArray
}
}
all this should be placed in in <HEAD> section of your HTML file:
<html>
<head>
...
<script language="javascript">
<!--
numbArray = new Array(,01235284563547
, 00123456789012, 00123456789012, ..... );
function FindNumber() {
for (i=0; i <= numbArray.length; i++)
{
if ( numbArray = yourForm.Project.options.selectedIndex )
yourForm.PONumber.value = numbArray
}
}
//-->
</script>
...
</head>
<body>
...
</body>
</html>
Important!
<select> and <textarea> fields sould be inside <form> ... </form> tag. I don't see it in your code.
"yourForm" is a name of a form:
<form name="yourForm"> and you can change it too. If form name is not specified, you have to change "yourForm" to forms[0], if it is the only form you have on your page. If there are some of them, change [0] to the number of it's appearance (starting from zero).
Also, you should call FindNumber() function somehow. You should add a small part to your SELECT:
<select size="1" name="Project" ID="Project" onChange="FindNumber()">
One more point. This system of number storage is static, and I think that you prefer something with databases. This is completely another story and I don't open it here. But if you manage to do it and afterwards create an array as I told, it will work good as well.
That's all if I'm not mistaken.
Hope it'll help you. But the better idea is to show all this to someone who knows a little bit the subject in order to modity/adapt everything to your specific needs.
Andrew | starway@mail.com