Skip to content Skip to sidebar Skip to footer

Submit Form With A New Value Using Javascript. (mvc)

Given a form with the following elements. I want to submit the

Solution 1:

With the following example:

<form name='myForm'>
  <inputtype='submit' name='subBtn' value='Submit' />
  <inputtype='submit' name='subBtn' value='Cancel' />
</form>

I used this:

// Intercept the 'onsubmit' functiondocument.myForm.onsubmit = function(){
  // Cycle through each name='subBtn'for (i = 0; i < this.subBtn.length; i++) {
    // Reset value property of current button in iterationthis.subBtn[i].value = "My Value";
  }
  // Prevent form submissionreturnfalse;
}

Demo Online: http://jsbin.com/aqenu

Post a Comment for "Submit Form With A New Value Using Javascript. (mvc)"