Skip to content Skip to sidebar Skip to footer

JQuery And IE Not Playing Nice

I have this section of code: function createDownload() { var category, format, specification, download; $('#submitform').click(function() { category =

Solution 1:

<form method="post" action="javascript: return false;" onSubmit="createDownload();">

Since you are using return false not in a function it is throwing the error. You will have to put that in an anynymous function.

Something like

<form method="post" action="javascript: function() {return false;}" onSubmit="createDownload();">

will work

Better to bind the event .submit() for the form

<form method="post" id="frm1"></form>

$("#frm1").submit(function(){
    // your code
    return false;
});

Solution 2:

You need to change your action='javascript: return false;' and remove the onsubmit. It should become action='javascript: createDownload();'


Solution 3:

Try removing the return. It seems you don't even need it, and if that's really the cause of the problem then what's the point keeping it there?


Solution 4:

First, you need to remove the action from the form - it serves no purpose here. Also, assuming #submitForm refers to the form submit button, your first click will attach the click handler and the second click will actually call it. Instead, remove the onsubmit attribute and just attach the handler in the usual way to either the button click or form submit event, being sure to cancel the event in either case:

jQuery(function($) {
    $('#submitform').click(function() {
    // or: $('#formID').submit(function() {
        var category, format, specification, download;

        category = $('#cate').val(); 
        format = $('#form').val(); 
        specification = $('#spec').val(); 

        if (category == "NULL" || format == "NULL" || specification == "NULL") { 
            alert("Please select all options.");
        } else {
            download = "pdfs/"+specification+format+category+".pdf"; 
            window.open(download);
        }

        return false;
    });
});

Post a Comment for "JQuery And IE Not Playing Nice"