PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Hidden Field - getting the refering link TITLE (eg. a href="form" title="foo")

  1. I have a page (http://dogswithoutborders.org/foster-a-dog/dogs-who-need-a-foster/) that has multiple links to the same form using the buttons labelled "FOSTER ME".

    I would like to capture the link title in a hidden field so I know which FOSTER ME button was clicked to get to the form.

    I've gone through the documentation and threads about getting the referral URL but I'm stumped about how to get the title attribute.

    Many thanks for your assistance!

    Posted 11 years ago on Sunday January 6, 2013 | Permalink
  2. I don't know of a programmatic way to get the title of the link that landed them on the form page. Since the page is always the same, but there are multiple links on the page, I can see why the referring page would not work for you.

    How about making sure the form has a hidden field which can be populated dynamically, and give the hidden field a parameter name of 'from' and then send the query string with the same information as your title attribute?

    <a href="http://dogswithoutborders.org/foster-a-dog/foster-application/?from=I want to foster2 pound little girl" rel="2 pound little girl" title="I want to foster2 pound little girl"><span>Foster me</span></a>

    (I noticed no space after "I want to foster" and the name of the dog.)

    If you are creating those links programmatically, you should be able to add that query string in the same way you add the 'rel' and the title attribute.

    Posted 11 years ago on Monday January 7, 2013 | Permalink
  3. Sending the query string with the same information as the title attribute is exactly what I don't know how to do :)

    I'm using PODS CMS to create the listings and I have a variable "$need_name;" that pulls the name field and inserts it into the title field in my loop.

    Within the page I can call the title attribute this way (may not be exactly right, but something like this) but I don't know how to send that over to the form field.
    $links = $x->getElementsByTagName('link');
    $title = $links->item(0)->getAttribute('title');

    Hmph.

    eta: added the space, thanks :)

    eta 2-

    Something like

    function referral_url($form){
    //Grab the linke title and put it into a variable
    $links = $x->getElementsByTagName('link');
    $title = $links->item(0)->getAttribute('title');

    //Return that value to the form
    return esc_url_raw($title);
    }

    but actually correct :P

    Posted 11 years ago on Monday January 7, 2013 | Permalink
  4. I don't think we should go down the route of JavaScript as you have posted. Because you have the information you need already in the $need_name, we can use that. I am not familiar with PODS though. Can you show how the $need_name is being added to the title and rel right now? Maybe we can just use that same method to populate the query string at the end of the link.

    Posted 11 years ago on Monday January 7, 2013 | Permalink