HTML and Javascript Automated Document Erases Entries After OnClick Event -
I am automating a document with HTML and Javascript via MS Notepad. So far, I have a lot of text, some text boxes, and a button, which will execute a javascript function after entering one of the text boxes. This document is only partially completed; However, I noticed that after adding the entries to my text box and then press the button, delete all my entries I believe this is a postback issue of some sort; However, I thought that using a onlick event with Javascript would not execute a server-side command. Besides, my document is all client-side code. Actually, it's just text, HTML, and, currently, a JS function.
As a repetition, would anyone know that wiping my textbox entries after the onclick event was executed, and how is this happening? In addition, the onclick event executes the JS function, which is a statement that adds more text to the document.
Thanks,
DFM
If you have a & lt; Input type = "submit" & gt;
button, so when you submit the button, even if you have the onclick
handler. There are several ways to solve this *, but the easiest way to change the button to type = "button"
, which does not collect anything other than clicking it.
& lt; Input type = "button" onclick = "checkEntries ()" />
* Other solutions include return
to include your onclick
handler, as onclick = "checkEntries ( ); Return
& lt; form & gt;
element
onsubmit = "return false"
Comments
Post a Comment