使用getElementbyID()提交表单时无法执行任何操作

I am C++ Programmer and new to JS World.

This refers to my previous question.

How to submit form based on certain condition?

I am trying to submit my form using document.getElementById based on certain condition but there is no output.

<!doctype html>
<html lang="en">
<head>
 <script src="//code.jquery.com/jquery-1.10.2.js"></script>
</head>
<title>jQuery.post demo</title>
<body>
<meta charset="utf-8">
<div id="form-container" style="padding-top: 10px; padding-bottom: 10px;">

<script>
  var x=Math.random();;
  if(x > 0.5)
  {
      //document.writeln(x);
      document.getElementById('form-container').submit();
  }  
</script>
X Value: <input type="text" name="X"><br>
<br>
<p style="text-align: left;"><button type="button" id="submit-button">Submit</button></p>
</div>
</body>
<script>
$(document).ready(function(e) {
  $('#submit-button').click(function(event){
    $('#form-container').submit();
  )};
)};
</script>
</html>

You can't do a .submit() on a <div>! You need a <form> Tag with an Action and an method Attribute.

The action Atrribute tells the browser where he has to send the data and the method Attribute says on what way (POST or GET) to send the Data.

<form Action="process.php" method="POST">

Of course you can add an ID too, for the identification of the form.

You should use a form in your HTML and specify properties to allow form submission:

<form id="form-container" action="url to your action where the form submit request will hit" method="get">

Ref : http://www.tutorialspoint.com/html/html_form_tag.htm

you should submit form not div so include url and method type in form tag