开发者

jquery form submit go to new URL

Basically I am building a html banner that can be posted in blogs or on other webpages. All it is is a form with some options in a select element.

<form id='formElement' method='get' action='#'>
<select id='selectElement'>
<option value='united-kingdom'>UK</option>
<option value='ireland'>Ireland</option>
</select>
</form>  

This jQuery takes the value of the selected option, and then adds the value on the en开发者_如何学Cd of A URL and then opens the url.

  $(function() {
        $("#selectElement").change(function() {
            if ($(this).val()) {
             var country = $(this).val();
                window.open("http://www.mobell.co.jp/country/"+country+"/", '_parent');
                $("#formElement").submit();
            }
        });       
    });
});

This works fine if I preview and use the banner locally, but if I embed the banner in a blog post then when the form submits it just goes to the homepage of that URL.

Any ideas?

For some reason it works fine on js fiddle: http://jsfiddle.net/5pSTz/


It is possible that the resulting html in the blog site is not valid. For example if it is an ASP.NET site then you are likely creating a nested from, which is not allowed.

Otherwise the blog site might be deliberatly encoding or removing your JavaScript to combat cross site scripting.

It is hard to tell without seeing the blog site.


I have added the input form in an iframe, seems to work fine now, thanks anyway

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜