0

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">
2
  • where you defined exercisenew? Commented Feb 13, 2013 at 6:02
  • You have nothing in your action of your form, where it will get submitted ? Commented Feb 13, 2013 at 6:07

2 Answers 2

1
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.");
}
Sign up to request clarification or add additional context in comments.

Comments

0

create object for exercisenew

var exercisenew = document.getElementById("exercisenew")

and do all the stuffs you have done

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.