SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Jan 2005
    Location
    england
    Posts
    328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help with j query ajax form

    Hi
    i am new to java scripting
    i have a shopping list with items with a edit link
    HTML Code:
     <td class="a"></b><a href="#contactForm">edit</a></td>
    how would id do it so i can get the id of the item, normally i could do this
    HTML Code:
     <td class="a"></b><a href="edit.php?id=$id">edit</a></td>
    how do i get the id using #contactForm

    any idea's

  2. #2
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,941
    Mentioned
    215 Post(s)
    Tagged
    12 Thread(s)
    Quote Originally Posted by pwesthead View Post
    how do i get the id using #contactForm
    Sorry, I don't quite understand your question.
    Which id do you mean?

    #contactForm is a fragment identifier.

    You can select the link whose href this is like so (using jQuery):

    Code JavaScript:
    $('a[href="#contactForm"]')

    or (vanilla JavaScript):

    Code JavaScript:
    var links = document.getElementsByTagName("a");
    for(var i=0, len = links.length; i < len; i++){
      hash = links[i].href.split('#')[1]	
      if(hash === "contactForm"){
        //do something with links[i]
      }
    }


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
  •