techie24by7@gmail.com writes:
>upon click of submit button in index.hmtl code, i want
>capture the values of r,c and update MapColumns, MapRows
>values in java script (script.js) and reload the page , how
>can i do that.
This is one of the most common applications of JavaScript:
handling of an input event from a form button.
Therefore, it is usually treated in most of the tutorials.
Here is one example:
Main.html
<!DOCTYPE HTML><html><head><meta charset="UTF-8">
<title>Main</title><link rel="stylesheet" href="main.css">
</head><body>
<form id="form0">
<p><input id="text0" value="beta"></input></p>
<p><input id="button0" type="button" value="evaluate"></P>
</FORM>
<script type="application/javascript;version=1.8" src="main.js">
</script></body></html>
main.css
(main.css is empty)
The script is called at the end of the body so that the
page body can be rendered fast without being delayed by
the loading of the script.
The script shows how to display a simple alert when the
button is clicked:
main.js
"use strict";
function onButtonClick()
{ "use strict";
alert( document.getElementById( "text0" ).value ); }
function wireButton()
{ "use strict";
document.getElementById( "button0" ).
addEventListener( "click", onButtonClick ); }
function onDOMContentLoaded()
{ "use strict";
wireButton(); }
function wireDOMContentLoaded()
{ "use strict";
document.addEventListener
( "DOMContentLoaded", onDOMContentLoaded, false ); }
wireDOMContentLoaded();
»wireDOMContentLoaded« will add »DOMContendLoaded« as an event
listener that will be called when the DOM content is loaded.
This in turn will wire »onButtonClick« as a an event listener
that will be called when the button has been clicked.
When the HTML file is displayed in a recent Firefox and the
button is being clicked, the alert with a text from a field
of the form should be display.
Instead of displaying an alert, you also could set your
global variables.
The above might only work under a recent Mozilla Firefox, it
still has to be modified to work under more widely used browsers.