jQuery target blank atr - where to include this in the script? -


i have following jquery script, deals query site-visitors enter search on external sites.

    $("#sbutton"+i).click(function(){         var my_id = $(this).attr('id').substr(8);         //alert(my_id);         searchurl = $('#search'+my_id).val();         searchquery = $('#string'+my_id).val();         location = searchurl+searchquery; 

currently, query loaded in same window query entered. i'd have in similar way 'target:_blank'. seems have use code ".attr("target","_blank")", can't seem figure out.

an me this?

thanks in advance!

here's can (or it):

<form class="searchform" target="_blank">    <input type="hidden" class="searchurl" />    <input type="text" class="searchquery" />    <input type="submit" /> </form> 

and js:

$(document).ready({   $(".searchform").bind("submit", function() {     var searchurl = $(this).children(".searchurl").val();     var searchquery = $(this).children(".searchquery").val();     var location = searchurl + searchquery;     $(this).attr("action",location);     $(this).submit();   }); }); 

the basic idea is, create handler on parent form element, finds appropriate data within , creates location string. event handler changes action of form new location string, , submits form.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -