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.

4

1 に答える 1

1

コード内のアンカー要素を 2 回閉じています...

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

次のようにする必要があります。

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

(アンカーの大なり文字の直前に削除された「/」に注意してください)

于 2013-08-14T13:00:58.970 に答える