Solved

jQuery

Posted on 2015-02-23
5
47 Views
Last Modified: 2015-02-24
I have a jQuery on Change function.  I need to make it into a onChange or on Submit Function.  I need both,  How do I write that?
<script>
	$(document).ready(function () {
		 $('select').change(function () { 

Open in new window

0
Comment
Question by:rgranlund
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 44

Accepted Solution

by:
Rainer Jeschor earned 500 total points
ID: 40626803
Hi,
you might try to create a dedicated function which can then be used when you bind it to the two events like
var customFunction = function() {
   ...
}
$('select').change(customFunction);
$('form').submit(customFunction);
...

Open in new window

HTH
Rainer
0
 
LVL 7

Author Comment

by:rgranlund
ID: 40627019
That did not really work.
0
 
LVL 44

Expert Comment

by:Rainer Jeschor
ID: 40627044
Hi,
I created a really small sample here
http://jsfiddle.net/EE_RainerJ/nvvu5mc8/

I prefer to use the "on" handler - but thats the only difference.
Could you perhaps add more info about your scripts?

HTH
Rainer
0
 
LVL 33

Expert Comment

by:Big Monty
ID: 40628156
just attach it to an onchange event handler, and within that code, do a form submit on whatever conditions warrant it:

$('select').change(function () {
       if ( this.val() == 4 )
             $(form).submit();
       else
              .....
}

Open in new window

0
 
LVL 7

Author Closing Comment

by:rgranlund
ID: 40628261
I wrote earlier that it did not work.  I looked everything over and I had a spelling error.  Sorry for making you post twice.  Thanks for your help!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

626 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question