SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    Feel my RewiredMind KMxRetro's Avatar
    Join Date
    Jan 2001
    Location
    Exeter, Devon, UK
    Posts
    477
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Quick and painless form question!

    Hi guys,
    Quick one for you... how do you reference the following object in JS?

    <input type="image" name="s1" src="myimage.gif">

    I basically want to change the src as part of another function...I've tried input["s1"] and image["s1"] to no avail! Help!

    Thanks in advance,

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2005
    Posts
    1,191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Document.getElementsByName("s1") returns everything with name="s1"
    or give your input a unique id : id="s1" and use
    Document.getElementById("s1")

  3. #3
    SitePoint Zealot bensheard's Avatar
    Join Date
    Jun 2006
    Location
    Cape Town | South Africa
    Posts
    117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thats the best way.
    Than you just go
    var whatever = document.getElementsByName("s1");
    whatever.src = new_source;
    Ben Sheard
    -------------
    Log all your dives easily and quickly from anywhere in the world
    www.divinglogs.cafe150.com

  4. #4
    Feel my RewiredMind KMxRetro's Avatar
    Join Date
    Jan 2001
    Location
    Exeter, Devon, UK
    Posts
    477
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Superb! Thanks guys!


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
  •