javascript - Best way to generate, and then open a URL using JQuery -


i trying open webpage on new window buy building url based off of users input. issue im running open new window, not use generated url. open about:blank window instead.

i put code in jsfiddle, , works there, can't figure out why not working on page. jsfiddle leaves original page saying [object], can't figure out either.

any appreciated.

http://jsfiddle.net/cmirab/shfgw/2/

html:

 <form id="search" name="safe">     <h1>how safe</h1>     <h2>is neighborhood?</h2>     <p class="p1">enter zip find crime statistics in area:</p>     <input type="text" name="search">     <input type="hidden" name="url" id="url">     <a class="button1" href="javascript:window.open(document.safe.url.value)">search</a>     </form> 

jquery var partfields = $('#search').val('#search').not('#url');

$(partfields).change(function() { var urlb = 'http://classic.crimereports.com/map?'; var urle = '&searchbutton.x=0&searchbutton.y=0'; var urlvalue = urlb + partfields.serialize() + urle;  $('#url').val(urlvalue); // set hidden input value }); 

css:

 #search {background:#232426;padding:5px 0 21px 24px;color:#737985;margin:0 0 30px;line height:15px;}     #search h1 {font-size:71px;line-height:1.2em;color:#ffad01;letter-spacing:-4px;}     #search h2 {font-size:35px;letter-spacing:-1px;margin:0 0 10px;}     #search input {border:none;background:#37383a;padding:9px 10px;margin:0 4px 0 0;width:240px;} 

try instead, modified of js , markup well. jsfiddle

var $searchbox = $('#search input[name="search"]')     $searchbox.change(function() {     var urlb = 'http://classic.crimereports.com/map?';     var urle = '&searchbutton.x=0&searchbutton.y=0';     var urlvalue = urlb + $searchbox.serialize() + urle;      $('.button1').attr('href',urlvalue); // set hidden input value });​   <form id="search" name="safe" >                     <h1>how safe</h1>                     <h2>is neighborhood?</h2>                     <p class="p1">enter zip find crime statistics in area:</p>                     <input type="text" name="search">                     <input type="hidden" name="url" id="url">                     <a class="button1" href="javascript:window.open(document.safe.url.value)" target="_blank">search</a>                 </form>​ 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -