I have a asp htmleditor where the user will enter any text or a message...is there any javascript to save the message every 5 seconds as drafts in vb.net .
A:
As your question is not much clear, I am assuming that you want to save the text in the database and let's say the htmleditor is some simple text area. So, you need to do two things to save the texts of the htmleditor as draft.
- Do a ajax call which will do the saving part.
- Use javascript function
setInterval()
for doing ajax call repeatedly for some given (in your case 5 sec) time interval.
So let's say saveHtmlEditorText()
is the function which does an ajax call to save the text. And now you have to initialize the setInterval()
, you can use the document.ready()
to initialize.
setInterval("saveHtmlEditorText()",5000);
You can see more about setInterval()
here.
Bipul
2010-03-30 06:19:24
you are absolutely correct. I have to save the text in database. I am sorry i did not mention that. And thank you for your quick response. I will definitely give a try on that.
ahmed
2010-03-30 06:24:59
Never pass strings to setInterval, you can pass the function directly:setInterval(saveHtmlEditorText, 5000);
Jonas H
2010-03-30 06:33:26