Hi, I’m fairly new (well, extremely new to javascript) and i’m trying to create a very simple form that will show some information based on what was selected in one box only. That’s easy. But i have a LOT of options (it’s a contact list).
I’ve done a [i]tiny
When i load the page i get two error reports: one is simply a missing ; but i don’t think that’s a biggie…could be wrong. The major problem seems to be that on line 62 – the <input name=”num”… line – its expecting an object and i clearly haven’t given it one somehow. Am i being too pure java in my thought processes. I’ve cut the script down to the basics and set it below…any suggestions would be massively appreciated.
Cheers
Al
p.s. there is also the problem that in the select box (name) it comes up as “numarrary[i]” instead of the value of that entry in the array. I’m guessing that’s just me not doing something right moving from java to jscript…or something simplish.
[code]
<head>
<script>
function numReturn()
{
var numarray = array();
// set all the entries to their appropriate values. Name, then number,then email prefix, then email suffix
numarray[0] = “Joe Bloggs”;
numarray[1] = “0800 000 0000”;
numarray[2] = “joe.bloggs”;
numarray[3] = “host.com”;
numarray[4] = “someone else”;
numarray[5] = “12345678”;
numarray[6] = “anyone”;
numarray[7] = “anywho.com”;
document.telNo.name.selectedIndex;
document.telNo.num.value;
if (document.telNo.name.selectedIndex == 1) {document.telNo.num.value = “Tel no:”+numarray[1]+”, “+numarray[2]+”@”+numarray[3];}
if (document.telNo.name.selectedIndex == 2) {document.telNo.num.value = “Tel no:”+numarray[5]+”, “+numarray[6]+”@”+numarray[7];}
If (document.telNo.name.selectedIndex == “x” || document.telNo.date.selectedIndex == “y”) return;
}
</script>
</head>
<body>
<form name=”telNo”>
<table>
<tr>
<td > <b>Telephone Number Retreival</b></font>
</td>
</tr>
<tr>
<td>
<b> Name </b>
</td>
<td rowspan=”2″>
<b> <b>:</b> </b>
</td>
<td>
<b> Tel No. </b>
</td>
</tr>
<tr>
<td>
<select name=”name” onChange=”document.telNo.num.focus();”>
var numarray = dataarray();
<option value=”x” selected>< Select > </option>
<option value=”1″>numarray[0]</option>
<option value=”2″>numarray[4]</option>
</select>
</td>
<td>
<input name=”num” size=”12″ value=”??” onFocus=”numReturn();” onBlur=”reset();” />
</td>
</tr>
</table>
</form>
</body>