select in form

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • twopeak

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

    what am I doing wrong?

    thanks for all help

    Code:

    <html><head></head><body>


    <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];
    }

    </script>
    </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;
    <br>
    <textarea name="bericht" rows="10" cols="30"></textarea><br>
    </form>
    </p>
    </body>
    </html>



  • Janwillem Borleffs

    #2
    Re: select in form


    "twopeak" <twopeak@pandor a.be> schreef in bericht
    news:mkt4b.1191 8$Qj7.428167@ph obos.telenet-ops.be...[color=blue]
    >
    > When the document loads, the javascript function gets triggered a first[/color]
    time[color=blue]
    > 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)';[/color]

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

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


    JW



    Comment

    Working...