JavaScript Behavior Without Onclick Event?

Discussion in 'Javascript' started by pbd22, Sep 11, 2009.

  1. pbd22

    pbd22 Guest

    Hi.

    I have recently been looking at the source of a number
    of sites and I have noticed that while elements on a
    page do not have an onclick attribute, they fire JavaScript
    behavior. For example, if I click on any of the below "options",
    something happens (that depends on the value of the option
    I clicked on).

    How is this done without using an onclick attribute (pls. excuse
    my newbieness). Could somebody illustrate (code appreciated)
    how I can grab the value of the option clicked on?

    <select id=sel1 name=sel1>
    <option value="234">Option1</option>
    <option value="235">Option2</option>
    <option value="236">Option3</option>
    <option value="237">Option4</option>
    <option value="238">Option5</option>
    <option value="239">Option6</option>
    </select>

    Thanks in advance.
     
    pbd22, Sep 11, 2009
    #1
    1. Advertising

  2. On Sep 11, 2:55 pm, pbd22 <> wrote:
    > Hi.
    >
    > I have recently been looking at the source of a number
    > of sites and I have noticed that while elements on a
    > page do not have an onclick attribute, they fire JavaScript
    > behavior. For example, if I click on any of the below "options",
    > something happens (that depends on the value of the option
    > I clicked on).
    >
    > How is this done without using an onclick attribute (pls. excuse
    > my newbieness). Could somebody illustrate (code appreciated)
    > how I can grab the value of the option clicked on?
    >
    > <select id=sel1 name=sel1>
    > <option value="234">Option1</option>
    > <option value="235">Option2</option>
    > <option value="236">Option3</option>
    > <option value="237">Option4</option>
    > <option value="238">Option5</option>
    > <option value="239">Option6</option>
    > </select>
    >
    > Thanks in advance.


    http://www.google.com/search?hl=en&q=javascript event binding
     
    Hamish Campbell, Sep 11, 2009
    #2
    1. Advertising

  3. pbd22

    pbd22 Guest

    On Sep 10, 9:38 pm, Hamish Campbell <> wrote:
    > On Sep 11, 2:55 pm, pbd22 <> wrote:
    >
    >
    >
    > > Hi.

    >
    > > I have recently been looking at the source of a number
    > > of sites and I have noticed that while elements on a
    > > page do not have an onclick attribute, they fire JavaScript
    > > behavior. For example, if I click on any of the below "options",
    > > something happens (that depends on the value of the option
    > > I clicked on).

    >
    > > How is this done without using an onclick attribute (pls. excuse
    > > my newbieness). Could somebody illustrate (code appreciated)
    > > how I can grab the value of the option clicked on?

    >
    > > <select id=sel1 name=sel1>
    > > <option value="234">Option1</option>
    > > <option value="235">Option2</option>
    > > <option value="236">Option3</option>
    > > <option value="237">Option4</option>
    > > <option value="238">Option5</option>
    > > <option value="239">Option6</option>
    > > </select>

    >
    > > Thanks in advance.

    >
    > http://www.google.com/search?hl=en&q=javascript event binding


    Thanks, that did the tick. I have a follow-up question but i will re-
    post as it is mostly off topic.

    Thanks again.
     
    pbd22, Sep 11, 2009
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. JerryG
    Replies:
    0
    Views:
    442
    JerryG
    Dec 20, 2005
  2. Steve Richter
    Replies:
    0
    Views:
    530
    Steve Richter
    Aug 1, 2007
  3. bob
    Replies:
    3
    Views:
    212
  4. Replies:
    2
    Views:
    272
  5. Replies:
    4
    Views:
    198
Loading...

Share This Page