AJFMEDIA
AJFMEDIA

Reputation: 2123

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 end 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/

Upvotes: 0

Views: 1381

Answers (2)

AJFMEDIA
AJFMEDIA

Reputation: 2123

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

Upvotes: 0

Buh Buh
Buh Buh

Reputation: 7545

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.

Upvotes: 1

Related Questions