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>