Tag: Js

Dynamically create form in javascript on fly

To create a form dynamically using JavaScript on fly of the webpage. This which helps to create form and input controls dynamically. [javascript] /* To create form with javascript */ var form = document.createElement("form"); form.setAttribute(‘method’,"post"); // form method form.setAttribute(‘action’,"test.php"); // form action url form.setAttribute(‘name’,"frmName"); // form name form.setAttribute(‘id’,"frmId"); // form ID form.setAttribute(‘target’,"_blank"); // form target …

Continue reading

Permanent link to this article: https://blog.openshell.in/2013/12/dynamically-create-form-in-javascript-on-fly/

Warning before navigate away from a page

In some cases, if you are in between any work of editing or typing a content, and you wont let the visitor to navigate away from the page without particular condition, say the document is not saved yet, you can block the navigation (even the closing of the browser window) with Javascript. Code: window.onbeforeunload = …

Continue reading

Permanent link to this article: https://blog.openshell.in/2011/02/warning-before-navigate-away-from-a-page/