0

I have this part of code which is suppose to pass values from my dataset to a gridview.

 var row = $("[id*=gvPlastic] tr:last-child").clone(true);
 var codes = $(this).find("Code").text();
  if  ($(this).find("Stock").text() == 'Y') {
      $("td", row).eq(7).html('<a href="#" onclick="getStock()" value=' + codes + ' />' + codes + '</a>');
     }
      else {
       $("td", row).eq(7).html($(this).find("Stock").text());
        }

How ever the variable code is outside the link i.e shown below:

<a value="80043" onclick="getStock()" href="#"></a>
80043

I am binding a gridview using jquery. My intention was the boundfield Stock be clickable if value is Y.

1 Answer 1

1

You are closing the anchor element in your code twice...

<a href="#" onclick="getStock()" value=' + codes + ' />' + codes + '</a>

Should be:

<a href="#" onclick="getStock()" value=' + codes + '>' + codes + '</a>

(note the removed "/" right before the anchor's greater-than character)

Sign up to request clarification or add additional context in comments.

1 Comment

TThanks a lot! Didn't notice that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.