SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Aug 2006
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    problem with getElementById input button id=""

    Hello everyone,
    I have to ids in my input button, does anyone knows how to declare two ids or away around so my form can work?

    This is what I have and does not work:

    Code:
    <input name="submit" type="image" src="playing.jpg" onClick="SLIDE_play();" id="SLIDE_play" id="button1"> 
    <input name="submit" type="image" src="paused.jpg" onClick="SLIDE_pause();" id="SLIDE_pause" id="button2">
    Thanks in advance mperez5

  2. #2
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    You cannot have two id's for one element. And why would you need that?
    Saul

  3. #3
    SitePoint Member
    Join Date
    Aug 2006
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    two scripts using id

    Hello php_daemon,
    I have two scripts that work fine independently. I need to put them together both of them are using getElementById; therefore it needs to be call in the <input id="" so I do not know how to make work together?
    This one:
    Code:
    <script type="text/javascript">
    function button1click()
    {
      var button1 = document.getElementById("button1");
      var button2 = document.getElementById("button2");
       if (button2.src.lastIndexOf("paused.jpg") > -1)
      {  
    	button1.src = "playing.jpg";
    	button2.src = "pause.jpg";
      } 
    }
    function button2click()
    {    
      var button1 = document.getElementById("button1");
      var button2 = document.getElementById("button2");
      if (button1.src.lastIndexOf("playing.jpg") > -1)
      {  
    	button1.src = "play.jpg";
    	button2.src = "paused.jpg";
      }
    }
    </script>
    <form name="myform" onsubmit="return false">
          <input id="button1" type="image" name="submit" src="playing.jpg" onClick="button1click()"> 
          <input id="button2" type="image" name="submit" src="pause.jpg" onClick="button2click()"> 
    </form>
    Thanks for using your precious time with my code.
    mperez5

  4. #4
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Use the same id values in both scripts. You have id="button1" and id="button2", you use those in your script, so make the other script use them too.
    Saul

  5. #5
    SitePoint Member
    Join Date
    Aug 2006
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    it works

    I just change the same id and it works, thanks a lot. I was thinking having to fuctions just like when using onClick function. Thanks a million

  6. #6
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    You're welcome
    Saul


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
  •