Form How To

by Blueprinter

HTML

<p>Putting a button, . . . ANY kind of a button inside of FORM tags, seems to cause the form to RESET after the form is submited.  If you want the values to stay in the form, then you need to put the button OUTSIDE of the form.  </p>
<form name="input" onsubmit="fncGetChkValues()" method="post">
  <input type="checkbox" name="same_day" value="someValOne">Same Day<br>
  <input type="checkbox" name="8-hours" value="someValTwo" id ="8_hours">8-hours 
  <br><br>
  <input type="submit" value="Submit">
</form> 

<p>Please click the SUBMIT button after making your choices</p>
      
      <div id='divMsgSameDay'></div>

JavaScript

window.fncGetChkValues = function(argFormObjValues) {
    //console.log('argFormObjValues: ' + argFormObjValues);
    document.getElementById('divMsgSameDay').textContent = argFormObjValues['same_day'];
      
    //console.log('argFormObjValues: ' + argFormObjValues[8-hours]);
  };