0

The command "alert(numOne);" shows f_name. Thus, I want the the last line of the function to become document.f_name.submit(); but my current idea doesn't work. Is there a way to make this happen?

    function submitform(e)
{
    var numOne = e.id;
    alert(numOne);
    if (        confirm("Proceed?")){
          document.numOne.submit();
        }

}
user5095266
  • 119
  • 2
  • 7

1 Answers1

0

You can use bracket notation for this purpose,

document[numOne].submit();

And your full code would be,

function submitform(e) {
  if (confirm("Proceed?")) {
    document[e.id].submit();
  }
}
Rajaprabhu Aravindasamy
  • 66,513
  • 17
  • 101
  • 130