Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

jQuery

Posted on 2015-02-23
5
Medium Priority
?
48 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 2000 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

Certified OpenStack Administrator Course

We just refreshed our COA course based on the Newton exam.  With 14 labs, this course goes over the different OpenStack services that are part of the certification: Dashboard, Identity Service, Image Service, Networking, Compute, Object Storage, Block Storage, and Orchestration.

Question has a verified solution.

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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
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

670 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