sumit garg
sumit garg

Reputation: 31

Java script not submitting Html form

I am using following javascript to submit the form but it's not submitting.

 if(timeup)
        {
         alert("welcome to time up.");
        var id = document.getElementById("test_id").value;
        var no = document.getElementById("noq").value;
      var action = 'result.php?id='+id+'&no='+no+'';

    exercisenew.action = action;
    alert("form"+exercisenew.action);
   exercisenew.submit();
       alert("form submitted.");
    }

full code here.

Html form.

<form method="post" action="" id="exercisenew" name="exercisenew">

Upvotes: 0

Views: 73

Answers (2)

user1646111
user1646111

Reputation:

if(timeup)
{
  alert("welcome to time up.");
  var id = document.getElementById("test_id").value;
  var no = document.getElementById("noq").value;

  //use encodeURIComponent()
  var action = encodeURIComponent('result.php?id='+id+'&no='+no+'');

  //get the form
  var exercisenew = document.getElementById("exercisenew")
  exercisenew.action = action;

  alert("form"+exercisenew.action);
  exercisenew.submit();
  alert("form submitted.");
}

Upvotes: 1

Java Questions
Java Questions

Reputation: 7963

create object for exercisenew

var exercisenew = document.getElementById("exercisenew")

and do all the stuffs you have done

Upvotes: 0

Related Questions