Shouldn't this work ? ...

R

Robin

I'm not very good at js, so I'm guessing that I definitely have something
wrong here ...
<head>
<script language="JavaScript">
function testFunc(form){
var tmp1 =
document.form.site.options[document.form.site.selectedIndex].value;
document.write tmp1
}
</script>
</head
.... <form method='post' name='form'>
<select name="site" onChange="javascript:testFunc(this)">
<option value='#'>--- (Select Site) ---
(there is a list here of <option value=".... > that is called
from a db)
</select>

Anyway, nothing is happening onChange
Where have I gone wrong?????
 
H

Hywel

I'm not very good at js, so I'm guessing that I definitely have something
wrong here ...
<head>
<script language="JavaScript">
function testFunc(form){
var tmp1 =
document.form.site.options[document.form.site.selectedIndex].value;
document.write tmp1
}
</script>
</head
... <form method='post' name='form'>
<select name="site" onChange="javascript:testFunc(this)">

You don't need the "javascript:" in the onChange event for starters, and
your document.write statement should be
document.write (tmpl);
 
R

Robin

thanks. Silly mistake, really.

Hywel said:
I'm not very good at js, so I'm guessing that I definitely have something
wrong here ...
<head>
<script language="JavaScript">
function testFunc(form){
var tmp1 =
document.form.site.options[document.form.site.selectedIndex].value;
document.write tmp1
}
</script>
</head
... <form method='post' name='form'>
<select name="site" onChange="javascript:testFunc(this)">

You don't need the "javascript:" in the onChange event for starters, and
your document.write statement should be
document.write (tmpl);
 
E

Evertjan.

Hywel wrote on 14 apr 2004 in comp.lang.javascript:
I'm not very good at js, so I'm guessing that I definitely have
something wrong here ...
<head>
<script language="JavaScript">
function testFunc(form){
var tmp1 =
document.form.site.options[document.form.site.selectedIndex].value;
document.write tmp1
}
</script>
</head
... <form method='post' name='form'>
<select name="site" onChange="javascript:testFunc(this)">

You don't need the "javascript:" in the onChange event for starters,
and your document.write statement should be
document.write (tmpl);

And you cannot do a document.write in an onchange without destroying the
whole page.

Do an alert(tmp1) or a mydiv.innerHTML = tmp1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,571
Members
45,045
Latest member
DRCM

Latest Threads

Top