469,336 Members | 5,360 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,336 developers. It's quick & easy.

select in form

Hello

I'm making a script, that should allow users to change a select box, and
this changes the alt and the src of several images.

I have made a script (see under) that exactly does what it's supposed to do!
My problem is that this was just a page to test,
now I'm implementing it in my page
And as soon as the select box is inside the form, when I change the select I
get an error "this object doesn't support this property"

When the document loads, the javascript function gets triggered a first time
without a problem, so the error has to be something about the
<select name="set" onChange="verander(this.value)">

what am I doing wrong?

thanks for all help

Code:

<html><head></head><body>
<html><head><title>javascript</title></head><body>
<script language="javascript">

function addsmile(image_name) {
var smiley;
smiley = document.images[image_name].alt;
doc_content = document.gb.elements['bericht'].value + smiley;
document.gb.elements['bericht'].value = doc_content;
document.gb.elements['bericht'].focus();
}
function verander(set) {
var sources = new Array(10);
var alttags = new Array(10);
if (set == 'set1') {
sources[1] = /smileys/blu4.gif'; alttags[1] = ' (cactus)';
sources[2] = /smileys/blume5.gif'; alttags[2] = ' @-\'-,-';
sources[3] = /smileys/blume5.gif'; alttags[3] = ' (roos)';
sources[4] = /smileys/booze.gif'; alttags[4] = ' (alkol)';
sources[5] = /smileys/freak.gif'; alttags[5] = ' (freak)';
} else if (set == 'set2') {
sources[1] = /smileys/partyf.gif'; alttags[1] = ' (punk)';
sources[2] = /smileys/perfect.gif'; alttags[2] = ' (y)';
sources[3] = /smileys/puke.gif'; alttags[3] = ' :#';
sources[4] = /smileys/puke.gif'; alttags[4] = ' :-#';
sources[5] = /smileys/slet.gif'; alttags[5] = ' (slet)';
} else if (set == 'set3') {
sources[1] = /smileys/smoke.gif'; alttags[1] = ' :-Q';
sources[2] = /smileys/worshippy.gif'; alttags[2] = ' <<:)>>';
sources[3] = /smileys/superman.gif'; alttags[3] = ' (reno)';
sources[4] = /smileys/mario.gif'; alttags[4] = ' (gio)';
sources[5] = /smileys/cartman.gif'; alttags[5] = ' (cartman)';
}
var begin = "";
document.images['een'].src = begin + sources[1]; document.images['een'].alt
= alttags[1];
document.images['twee'].src = begin + sources[2];
document.images['twee'].alt = alttags[2];
document.images['drie'].src = begin + sources[3];
document.images['drie'].alt = alttags[3];
document.images['vier'].src = begin + sources[4];
document.images['vier'].alt = alttags[4];
document.images['vijf'].src = begin + sources[5];
document.images['vijf'].alt = alttags[5];
}

</script>
</head><body onLoad="verander('set1')">
<select name="verander" onChange="verander(this.value);">
<option value="set1">set1</option><option value="set2">set2</option><option
value="set3">set3</option><option value="set4">set4</option><option
value="set5">set5</option><option value="set6">set6</option><option
value="set7">set7</option><option value="set8">set8</option><option
value="set9">set9</option><option value="set10">set10</option><option
value="set11">set11</option><option value="set12">set12</option><option
value="set13">set13</option><option value="set14">set14</option><option
value="set15">set15</option><option value="set16">set16</option> </select>
<form name="gb" action="test.html" method="post">
<a href="javascript:addsmile('een')"> <img name="een" src="" alt=""
border="0" height="32"></a> &nbsp;
<a href="javascript:addsmile('twee')"> <img name="twee" src="" alt=""
border="0" height="32"></a> &nbsp;
<a href="javascript:addsmile('drie')"> <img name="drie" src="" alt=""
border="0" height="32"></a> &nbsp;
<a href="javascript:addsmile('vier')"> <img name="vier" src="" alt=""
border="0" height="32"></a> &nbsp;
<a href="javascript:addsmile('vijf')"> <img name="vijf" src="" alt=""
border="0" height="32"></a> &nbsp;
<br>
<textarea name="bericht" rows="10" cols="30"></textarea><br>
</form>
</p>
</body>
</html>

Jul 20 '05 #1
1 2095

"twopeak" <tw*****@pandora.be> schreef in bericht
news:mk********************@phobos.telenet-ops.be...

When the document loads, the javascript function gets triggered a first time without a problem, so the error has to be something about the
<select name="set" onChange="verander(this.value)">

what am I doing wrong?

if (set == 'set1') {
sources[1] = /smileys/blu4.gif'; alttags[1] = ' (cactus)';


You are missing out on the quotes. Per example, the line above should read:

sources[1] = '/smileys/blu4.gif'; alttags[1] = ' (cactus)';
JW

Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by point | last post: by
1 post views Thread by John Fung | last post: by
4 posts views Thread by bobsawyer | last post: by
5 posts views Thread by GTi | last post: by
2 posts views Thread by areef.islam | last post: by
7 posts views Thread by srt5k | last post: by
1 post views Thread by CARIGAR | last post: by
1 post views Thread by haryvincent176 | last post: by
reply views Thread by Marylou17 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.