Your code don't work because with $("#property_links") you retreive
every hidden input with that id, then val() return value only for the
first. You have to access only the correct hidden input: you can use a
find that search for a query in all the children of the clicked p

You have to replace

var prop = $("#property_links").val();

with

var prop = $(this).find("#property_links").val();

By the way, it is not reccomanded to have more then one element with same id

Paolo

On Tue, Aug 25, 2009 at 3:30 PM,
arysal...@hotmail.com<arysal...@hotmail.com> wrote:
>
> Hi Guys,
>
> I am having difficulty getting the value of a specific value contained
> in a <p> tag. What is happening is that it retrieves the value of the
> first <p> tag value and not the on the user clicks.
>
> What I need is to retieve the value from the <p> tag the user click.
>
> Snippet code [BEGIN]:
>
> $(document).ready(function() {
>
>   $("p").click(function () {
>   var prop = $("#property_links").val();
>   $.post("n10-shortlist-connector.html", { web_AGENT_REF: prop});
>         var htmlStr = "Added to Compare Tool";
>       $(this).text(htmlStr);
>                     });
>
>                  });
>
>
> <p><a style="cursor:pointer; color: #900">  Add to Compare Tool <input
> type="hidden" id="property_links" value="<? echo $AGENT_REF; ?>"/></
> a></p>      //    many of these tags on the page
>
> Snippet code [END]:
>
> view page: http://nwbeta.itproz.co.uk/residenti...tion=Liverpool
> If viewing the site when you click "add to compare list" it will
> change to "Added to compare list"
>
> All help appreciated,
> Thanks in advance.
>

Reply via email to