Multiple onClick="" actions?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Keenan
    New Member
    • Jun 2010
    • 1

    Multiple onClick="" actions?

    Hello,

    I am using this code

    Code:
    <form style="display: none;" name="num1form" id="num1form" action="">
    <input type="image" name="1" id="num1" value="1" src="imgl/img_first_01.png" onclick="document.forms[0].action='javascript:ChangeNum1();'"/>
    </form>
    What the above code does is change the action state, it allows me to have multiple image inputs which is great as I can define various inputs with different IDs.

    However, this is used for one section of the page I happen to have another <form> with basically the same code but it's using num2 values, I'm not sure why but I can only using one of these
    Code:
    onclick="document.forms[0].action='javascript:ChangeNum1();'"


    at a time, for one form only.

    Is there anyone able to help me divide this, or make these onClick actions unique so they can be used in more than 1 form?

    Thanks,
    Keenan
  • RamananKalirajan
    Contributor
    • Mar 2008
    • 608

    #2
    This code

    Code:
    document.forms[0].action='javascript:ChangeNum1();'
    is having 0 in forms[] that should be changed according to the form no which it is placed

    for ex:
    Code:
       <form style="display: none;" name="num1form" id="num1form" action="">
       <input type="image" name="1" id="num1" value="1" src="imgl/img_first_01.png" onclick="document.forms[0].action='javascript:ChangeNum1();'"/>
       </form>
    
    <form style="display: none;" name="num2form" id="num2form" action="">
       <input type="image" name="2" id="num2" value="2" src="imgl/img_first_02.png" onclick="document.forms[1].action='javascript:ChangeNum1();'"/>
       </form>
    Thanks and Regards
    Ramanan Kalirajan

    Comment

    • Dormilich
      Recognized Expert Expert
      • Aug 2008
      • 8694

      #3
      you are aware that a form’s action must be an URL?

      Comment

      • RamananKalirajan
        Contributor
        • Mar 2008
        • 608

        #4
        Yes Dormilich I am aware but this guys has written the code works fine for him. I gave the suggestion how to do what he is asking for.

        Thanks and Regards
        Ramanan Kalirajan

        Comment

        Working...