dcsimg
www.webdeveloper.com
Results 1 to 1 of 1

Thread: Get Name ID?

  1. #1
    Join Date
    Jan 2006
    Location
    England UK
    Posts
    200

    Get Name ID?

    Hey

    I was wondering how would i get like an id value so i could do something like this:

    I have 2 fields and a div (status).

    HTML Code:
    <input name="item_1" type="hidden" value="1" /> 
    <input type="text" name="date_1" id="dateselect" onchange="check();" />
    <div id="status_1">Click on the field above!</div> 
    
    <input name="item_2" type="hidden" value="2" /> 
    <input type="text" name="date_2" id="dateselect" onchange="check();" />
    <div id="status_2">Click on the field above!</div>
    Thats 2 sets of field and there would be alot more! coded with PHP (foreach item).

    So i need to pass the values of these fields into a ajax request.

    HTML Code:
    date = $("[name='date']").val();
    item = $("[name='item']").val();
    elm = "#status";
    How would i get the "1" or "2" as a var called id, so i could do something like

    HTML Code:
    date = $("[name='date_"+id+"']").val();
    item = $("[name='item_"+id+"']").val(); or item = id;
    elm = "#status_"+id;
    Since there will be multiple of these mini checkers, doing the same but not at the same time, only when clicked. I can easily do it when there is only 1 but when there is like more then 1 im a little stuck.

    Thanks for any help
    Last edited by LiL|aaron; 08-20-2011 at 10:33 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles