Writing D:/inetpub/webs/vincenzodevivocom/wiki/data/cache/b/b76965abc605a42bd3d3f1822de31091.i failed
Unable to save cache file. Hint: disk full; file permissions; safe_mode setting.
Writing D:/inetpub/webs/vincenzodevivocom/wiki/data/cache/b/b76965abc605a42bd3d3f1822de31091.i failed
Unable to save cache file. Hint: disk full; file permissions; safe_mode setting.
Writing D:/inetpub/webs/vincenzodevivocom/wiki/data/cache/b/b76965abc605a42bd3d3f1822de31091.xhtml failed

Gestione dei Form in Javascript

Come chiedere la conferma prima dell'invio di un form

Javascript Confirm Form Submission

ConfirmForm.html
<script LANGUAGE="JavaScript">
<!--
  function confirmSubmit()
  {
    var agree=confirm("Are you sure you wish to continue?");
    if (agree)
      return true ;
    else
      return false ;
  }
// -->
</script>
 
<form method="POST" action="#" onsubmit="return confirmSubmit()" id="submitform" name="submitform">
    Premere il pulsante per provare <input type="Submit" value="Invia" id="Invia" name="Invia">
</form>

Ecco l'esempio funzionante:

Premere il pulsante per provare

Creare un form in POST e fare submit da javascript

PostForm.js
function getNewSubmitForm(){
 var submitForm = document.createElement("FORM");
 document.body.appendChild(submitForm);
 submitForm.method = "POST";
 return submitForm;
}
function createNewFormElement(inputForm, elementName, elementValue){
 var newElement = document.createElement("input");
 inputForm.appendChild(newElement);
 newElement.name =  elementName;
 newElement.type =  "hidden";
 newElement.value = elementValue;
 return newElement;
}
 
var submitForm = getNewSubmitForm();
createNewFormElement(submitForm, "par1", "false");
createNewFormElement(submitForm, "par2", "true");
submitForm.action= "http://www.vincenzodevivo.com";
submitForm.submit();

Creare un form in POST e fare submit da javascript (versione ridotta)

PostFormZip.js
(function (ps, url) {
  var d = document;
  var f = d.createElement('FORM');
  d.body.appendChild(f);
  f.method = 'POST';
  f.target = '_blank'
  for (p in ps) {
    var e = d.createElement('input');
    f.appendChild(e);
    e.name = p;
    e.type = 'hidden';
    e.value = ps[p];
  }
  f.action = url;
  f.submit();
})({
  par1: 'false',
  par2: 'true'
}, 'http://www.vincenzodevivo.com');
 
code/js/form.txt · Last modified: 2015/04/03 11:32 by Vincenzo De Vivo
 
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki