开发者

passing an input field value through a querystring using jquery

I trying to store the开发者_如何学C value of the input field tbEmail into str so when the user clicks the submit button the value of tbEmail will be added to the querystring. If i change this so that it reads var str = "this"; then this works. Is this the incorrect way to get an iput field value in jquery? Any ideas?

<script type="text/javascript">

    $(document).ready(function () {
        var str = $('#idofinputfield').val();
        $(".iframe").colorbox({ href: "/newsletter-lightbox.aspx?id=" + str, iframe: true, innerWidth: 590, innerHeight: 500 });

    });
</script> 


var str = $('#idofinputfield').val();

is the correct way. only you dont bind your code to a click try:

$('.clickme').live('click', function() {
    var str = $('#').val();
    $(".iframe").colorbox({ href: "/newsletter-lightbox.aspx?id=" + str, iframe: true, innerWidth: 590, innerHeight: 500 });
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜