How to submit form when jquery select is changed?

Experts,

I need help with my jQuery syntax.

How can I submit my form when my jquery UI select is changed?

<script>
$(function(){
	//DEFINE A SELECT MENU CLASS
	$(".select").selectmenu();
});
$(document).ready(function(){
	//AUTOMATICHALLY SUBMIT THE STOPPAGE DATE FORM IF DATE IS CHANGED
	$("#stoppage_date").change(function(){
		document.getElementById("stoppage_date_form").submit();
	});
});
</script>

Open in new window


<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" id="stoppage_date_form">
<select name="stoppage_date" id="stoppage_date" class="select">
    <option value="">Stoppage Date</option>
    <?php 
    if(!empty($_SESSION['stoppage_date'])){
        echo'<option value="'.$_SESSION['stoppage_date'].'">'.$_SESSION['stoppage_date'].'</option>';
    }
    ?>
    <option value="<?php echo date('m-d-Y'); ?>"><?php echo date('m-d-Y'); ?></option>
</select>
</form>

Open in new window

evibesmusicAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GaryCommented:
$("#stoppage_date").change(function(){ $("#stoppage_date_form").submit() })

Open in new window

0
evibesmusicAuthor Commented:
@Gary:

Sorry but, the following is still not working for me:

$(function(){
      //DEFINE A BUTTON CLASS
      $(".button").button();
      //DEFINE A SELECT MENU CLASS
      $(".select").selectmenu();
});
$(document).ready(function(){
      //AUTOMATICHALLY SUBMIT THE STOPPAGE DATE FORM IF DATE IS CHANGED
      $("#stoppage_date").change(function(){
            $("#stoppage_date_form").submit()
      })
});
0
GaryCommented:
Can you post the rendered HTML of the page
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

evibesmusicAuthor Commented:
Rendered code:
<!DOCTYPE HTML>
<html><!-- InstanceBegin template="/Templates/work_stoppage_template.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- InstanceBeginEditable name="doctitle" -->
<!-- InstanceEndEditable -->
<!-- BEGIN STYLE SHEETS -->
<link rel="stylesheet" type="text/css" href="css/styles.css"/>
<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.0/themes/sunny/jquery-ui.css" />
<!-- END STYLE SHEETS -->
<!-- BEGIN SCRIPTS -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.0/jquery-ui.min.js"></script>
<!-- BUTTON CLASS -->
<script>
$(function(){
	//DEFINE A BUTTON CLASS
	$(".button").button();
	//DEFINE A SELECT MENU CLASS
	$(".select").selectmenu();
});
$(document).ready(function(){
	//AUTOMATICHALLY SUBMIT THE STOPPAGE DATE FORM IF DATE IS CHANGED
	$("#stoppage_date").change(function(){ 
		$("#stoppage_date_form").submit()
	})
});
</script>
<!-- END BUTTON CLASS -->
<!-- LOG-IN SCRIPT -->
<!-- END LOG-IN SCRIPT -->
<!-- END SCRIPTS -->
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
</head>

<body>
    <!-- Begin Naviagtion -->
    <div id="navigation">
					<a href="./index.php" class="button">My Employees</a>
            <a href="./command_center.php" class="button">Command Center</a>
            <a href="./reports.php" class="button">Reports</a>
			<div style="float:right;">
                <form action="/work_stoppage/index.php" method="post" id="stoppage_date_form">
                    <select name="stoppage_date" id="stoppage_date" class="select">
                        <option value="">Stoppage Date</option>
                        <option value="08-10-2014">08-10-2014</option>                        <option value="08-09-2014">08-09-2014</option>
                        <option value="08-10-2014">08-10-2014</option>
                    </select>
                </form>
			</div>
        	</div>
    <!-- End Naviagtion -->
</body>
<!-- InstanceEnd --></html>

Open in new window

0
GaryCommented:
Remove the earlier code and change your plugin code to this

$(".select").selectmenu({
	change: function() {
		$("#stoppage_date_form").submit();
	}
});

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
evibesmusicAuthor Commented:
@Gary

Bingo! 500 Duffs...I mean...points to you!

Thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.