473,893 Members | 1,619 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

select in form


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="veran der(this.value) ">

what am I doing wrong?

thanks for all help


<html><head><ti tle>javascript</title></head><body>
<script language="javas cript">

function addsmile(image_ name) {
var smiley;
smiley = document.images[image_name].alt;
doc_content = document.gb.ele ments['bericht'].value + smiley;
document.gb.ele ments['bericht'].value = doc_content;
document.gb.ele ments['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];

</head><body onLoad="verande r('set1')">
<select name="verander" onChange="veran der(this.value) ;">
<option value="set1">se t1</option><option value="set2">se t2</option><option
value="set3">se t3</option><option value="set4">se t4</option><option
value="set5">se t5</option><option value="set6">se t6</option><option
value="set7">se t7</option><option value="set8">se t8</option><option
value="set9">se t9</option><option value="set10">s et10</option><option
value="set11">s et11</option><option value="set12">s et12</option><option
value="set13">s et13</option><option value="set14">s et14</option><option
value="set15">s et15</option><option value="set16">s et16</option> </select>
<form name="gb" action="test.ht ml" method="post">
<a href="Javascrip t:addsmile('een ')"> <img name="een" src="" alt=""
border="0" height="32"></a> &nbsp;
<a href="Javascrip t:addsmile('twe e')"> <img name="twee" src="" alt=""
border="0" height="32"></a> &nbsp;
<a href="Javascrip t:addsmile('dri e')"> <img name="drie" src="" alt=""
border="0" height="32"></a> &nbsp;
<a href="Javascrip t:addsmile('vie r')"> <img name="vier" src="" alt=""
border="0" height="32"></a> &nbsp;
<a href="Javascrip t:addsmile('vij f')"> <img name="vijf" src="" alt=""
border="0" height="32"></a> &nbsp;
<textarea name="bericht" rows="10" cols="30"></textarea><br>

Jul 20 '05 #1
1 2233

"twopeak" <tw*****@pandor a.be> schreef in bericht
news:mk******** ************@ph obos.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="veran der(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)';

Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: point | last post by:
Hello there... I'm a PHP programmer and starting to learn JS... I have a following problem.... I have 3 select boxes! one is hotel one is destination and one is country... if someone clicks selects the country then the destination select box shows the destinations in that country and further if he chooses destination all
by: John Fung | last post by:
Dear Everybody, I have a double menu select javascript, could anyone know how to change it, so that the result will display in a frame name called "content", please? Here is the script. <html><body> <script> <!--
by: Forti2ude | last post by:
Hello, I have a simple form... <form> <select name="foo" multiple> <option value="1">one</option> <option value="2">two</option> <option value="3">three</option> </select>
by: bobsawyer | last post by:
I've been building a series of SELECT lists that are populated dynamically using HTTPRequest. Things are going pretty well, and I've got the whole thing working flawlessly in Mozilla/Firebird. Unfortunately, Internet Explorer doesn't quite work as expected -- it gives me an "invalid argument" error that I don't know how to fix. Here's the entire script, with form, annotated to explain what I'm doing and where the problem is occurring. I...
by: William Wisnieski | last post by:
Hello Everyone, I have a main form with a datasheet subform that I use to query by form. After the user selects two criteria on the main form and clicks the cmdShowResults button on the main form, the subform returns the records based on the two criteria. The criteria used on the main form are values selected in two list boxes. When the user clicks on the first list box (lstCollege), it returns values in the second list box...
by: GTi | last post by:
Whats wring with this code? <select class=EditField size="1" name="PlantUnitID" title="Select line"> <option value="0" >Standalone Unit</option> <option value="1" selected >Connected Unit 1</option> <option value="1" selected >Connected Unit 2</option> </select> <span onclick="NewWindow('pluginpage.html?EditUnitGUID='+this.form.PlantUnitID.options.value+'&DoPostBack=1','namexx',200,310);"
by: areef.islam | last post by:
Hi, I am kinda new to javascript and I am having this problem with selecting multiple options from a select tag. Hope someone can help me out here. here is my code /////////////////////////////////////////////////////////////////////////////////////// <form action="whatever.php" method="post"> <select name="zip_code" onchange="makeRequest('getCity.php?state='+this.form.zip_code.options.value)" multiple="multiple" size="20">
by: srt5k | last post by:
I have a web page with 2 html multiple select boxes on it, and I use javascript to dynamicaly copy options from one box to another, before deleting the option from the first box. My issue is that in IE 7 more often than not after the option value has been deleted form.selone.options = null; the select box resets to the first item in the list, meaning that the
by: matwilko | last post by:
hi, i am trying to create a simple version of itunes...and i am using iframes to do this. I have already set up the iframes using dreamweaver and used a drop-down menu to select the genre. When selecting the genre the artists appears in iframe1...and i want to be able to select the artist so that the songs appear. I am unsure of how to do this, could anybody help? Thanks Here is my current code... <html> <head> <title>MiTunes</title>...
by: FlashCreations | last post by:
Hello, I am trying to use javascript to validate a form that has three select inputs. Here is the form: <form name="select" action="main.php" method="post" onsubmit="return ValidateSelect(this)"> <select name="one"> <option value="0" selected="selected">-Select An Option-</option> </select> <select name="two"> <option value="0" selected="selected">-Select An Option-</option> </select> <select name="three">
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.