Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old September 21st, 2005, 01:13 PM
Authorized User
 
Join Date: Jun 2003
Location: , , India.
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to tgopal
Default input type="image"

Hi
I want to get the id's and name's of the image tags in my form dynamically using javascript
Ex.
If i have
<input type="image" name="image1" id="image1">
<input type="image" name="image2" id="image2">

I want to get the name and ids of the above two tags dynamically

I tried with document.images and document.form.elements it is not working.
Any suggestions on this

Regards
Gopalakrishnan

  #2 (permalink)  
Old September 22nd, 2005, 05:15 AM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Gopalakrishnan,

Try this...
Code:
function FindImageFlds(){
    var f = document.getElementById("myFormId");
    var els = f.getElementsByTagName("input");
    for(var i = 0; i < els.length; i++){
        var e = els[i];
        if(e.type == "image"){
            alert("found an image field, id: " + e.id + "; name: " + e.name);
        }
    }
}
HTH,

Chris



Similar Threads
Thread Thread Starter Forum Replies Last Post
input type="image" tgopal Javascript How-To 1 September 22nd, 2005 05:16 AM
Problem with input type image With Anchor tag vinkumrect Javascript How-To 1 July 21st, 2005 08:59 AM
problem with input type="image" nerssi Javascript 6 September 14th, 2004 03:31 PM
<input type="File"> - Specify File Type and Path gp_mk Classic ASP Basics 2 August 2nd, 2004 03:07 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.