Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

add code to onsubmit handler

Posted on 2011-03-23
2
Medium Priority
?
302 Views
Last Modified: 2012-05-11
I am currently making a wysiwyg editor for an application, and trying to keep it as unobtrusive as I can.

the type of code I keep running into (which does work) looks like.

 
//set to always drop content into input box onsubmit;
		document.getElementById('wysiwyg_input:'+i).form.onsubmit = (
			function(i,old_onsubmit) {
				return function(){
					if(document.getElementById('wysiwyg_input:'+i))
						document.getElementById('wysiwyg_input:'+i).value = document.getElementById('wysiwyg_editor:'+i).innerHTML;
					if(old_onsubmit) old_onsubmit();
				}
			}
		)(i,document.getElementById('wysiwyg_input:'+i).form.onsubmit);

Open in new window


this code takes the value of the wysiwyg_editor and puts it into the wyswyg_input to be sumbitted by a form.  The i value is saying which wysiwyg_editor on the page it is because i loop through every one and assign this when they are created.

This code just is hard for me follow and although it does work i am looking for a better way of doing it.
0
Comment
Question by:brad0525
2 Comments
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 2000 total points
ID: 35204514
I think you are looking for attachEvent
 However the code you have is ok and works so why mess with the two versions of attaching events you need, one for IE<9 and one for the rest?
0
 

Author Comment

by:brad0525
ID: 35216749
looking into it, its not perfect but i like the attachEvent way better.

it makes it easier to put it in an outside function and clean up the main script.

Thank you for pointing me in the right directions
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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 the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
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…

926 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