Shouldn't this work ? ...

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

    Shouldn't this work ? ...

    I'm not very good at js, so I'm guessing that I definitely have something
    wrong here ...
    <head>
    <script language="JavaS cript">
    function testFunc(form){
    var tmp1 =
    document.form.s ite.options[document.form.s ite.selectedInd ex].value;
    document.write tmp1
    }
    </script>
    </head
    .... <form method='post' name='form'>
    <select name="site" onChange="javas cript: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?????


  • Hywel

    #2
    Re: Shouldn't this work ? ...

    In article <LTefc.14680$Yw 5.14146@bignews 4.bellsouth.net >,
    rlaxton@energym asterllc.com says...[color=blue]
    > I'm not very good at js, so I'm guessing that I definitely have something
    > wrong here ...
    > <head>
    > <script language="JavaS cript">
    > function testFunc(form){
    > var tmp1 =
    > document.form.s ite.options[document.form.s ite.selectedInd ex].value;
    > document.write tmp1
    > }
    > </script>
    > </head
    > ... <form method='post' name='form'>
    > <select name="site" onChange="javas cript:testFunc( this)">[/color]

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

    --
    Hywel I do not eat quiche


    Comment

    • Robin

      #3
      Re: Shouldn't this work ? ...

      thanks. Silly mistake, really.

      "Hywel" <hyweljenkins@h otmail.com> wrote in message
      news:MPG.1ae7a0 04e7957a22989b9 b@news.individu al.net...[color=blue]
      > In article <LTefc.14680$Yw 5.14146@bignews 4.bellsouth.net >,
      > rlaxton@energym asterllc.com says...[color=green]
      > > I'm not very good at js, so I'm guessing that I definitely have[/color][/color]
      something[color=blue][color=green]
      > > wrong here ...
      > > <head>
      > > <script language="JavaS cript">
      > > function testFunc(form){
      > > var tmp1 =
      > > document.form.s ite.options[document.form.s ite.selectedInd ex].value;
      > > document.write tmp1
      > > }
      > > </script>
      > > </head
      > > ... <form method='post' name='form'>
      > > <select name="site" onChange="javas cript:testFunc( this)">[/color]
      >
      > You don't need the "javascript :" in the onChange event for starters, and
      > your document.write statement should be
      > document.write (tmpl);
      >
      > --
      > Hywel I do not eat quiche
      > http://kibo.org.uk/
      > http://kibo.org.uk/mfaq.php[/color]


      Comment

      • Evertjan.

        #4
        Re: Shouldn't this work ? ...

        Hywel wrote on 14 apr 2004 in comp.lang.javas cript:[color=blue]
        > In article <LTefc.14680$Yw 5.14146@bignews 4.bellsouth.net >,
        > rlaxton@energym asterllc.com says...[color=green]
        >> I'm not very good at js, so I'm guessing that I definitely have
        >> something wrong here ...
        >> <head>
        >> <script language="JavaS cript">
        >> function testFunc(form){
        >> var tmp1 =
        >> document.form.s ite.options[document.form.s ite.selectedInd ex].value;
        >> document.write tmp1
        >> }
        >> </script>
        >> </head
        >> ... <form method='post' name='form'>
        >> <select name="site" onChange="javas cript:testFunc( this)">[/color]
        >
        > You don't need the "javascript :" in the onChange event for starters,
        > and your document.write statement should be
        > document.write (tmpl);[/color]

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

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


        --
        Evertjan.
        The Netherlands.
        (Please change the x'es to dots in my emailaddress)

        Comment

        Working...