SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2006
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Call a function twice in the same onchangue event

    Hi people!!

    Now I call a function with a onchange event in a <select>.

    <select name="client" id="client" onchange="myFunction('parameter_1, 'parameter_2')">
    ok, but I need call again the same function in the same <select>, I did try with:

    <select name="client" id="client" onchange="myFunction('parameter_1, 'parameter_2'), myFunction('parameter_3','parameter_4')">
    But it doesn't works

    Can anybody give me a small help?

    From now, thanks a lot for any help.

  2. #2
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <select name="client" id="client" onchange="myFunction('parameter_1, 'parameter_2'); myFunction('parameter_3','parameter_4')">
    A better way is to put this in an external javascript file:
    Code javascript:
    window.onload = function() {
      document.getElementById('client').onchange = function() {
        myFunction('param1', 'param2');
        myFunction('param3', 'param4');
      }
    }
    Then your HTML could be reduced to this:
    HTML Code:
    <select name="client" id="client">


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •