0

我正在使用链接按钮将页面重定向到我想要的位置,并使用来自 Jquery 的一些查询字符串值。链接按钮代码如下:

<td>
            <a id="selectAllLink" class="button" rel="nofollow ibox&width=800&height=400&title=Contact Now"
                href="#" onclick="return (this.href=='#');">Contact Selected</a>
        </td>

并且将在我的链接按钮的单击事件上创建/更新链接的 Jquery 如下:

function CotactSelected() {
    var a = [];
    var n = $("td.title_listing input:checked");
    var s = "";
    n.each(function() {
        a.push($(this).val());
    });
    var s = a.join(',');

    if (s != null) {
        $("@.button#selectAllLink").attr("href", "/D_ContactSeller.aspx?property=" + s);

    }
    else {
        alert("Select atleast one property to contact!");
    }
}

我想做的是它会从复选框中收集所有逗号分隔的值,并将其传递到另一个页面,并将收集的值作为查询字符串。单击该链接按钮时,它应该带有所有逗号分隔的值并重定向到所需的页面。请帮助我..在此先感谢。

4

2 回答 2

1

使用这个而不是你的功能CotactSelected

$(function() {
  $('#selectAllLink').each(function() {
    var a = [];
    var n = $("td.title_listing input:checked");
    var s = "";

    n.each(function() {
      a.push(this.value);
    });
    s = a.join(',');

    if (a.length > 0)
      this.href= "/D_ContactSeller.aspx?property=" + s;
    else
      this.href = 'javascript:alert("Select at least one property to contact!");';
    return false;
  });
});
于 2010-01-19T09:23:32.297 回答
0
if (s != null) {
  $("@.button#selectAllLink").attr("href", "");
  $("@.button#selectAllLink").attr("href", "/D_ContactSeller.aspx?property=" + s);
}
else {
    alert("Select atleast one property to contact!");
}

希望这可以帮助 :)

于 2010-01-19T07:55:05.153 回答