This is my jsfiddle(http://jsfiddle.net/mZGsp/). I was trying to answer a question here but my code won't work. Here is the code:
var stateOfClick = null;
function initiateLine(){
document.getElementById('test').innerHtml = "Started";
}
function endLine(){
document.getElementById('test').innerHtml = "Line Ended";
}
function createLines(){
if(!stateOfClick) {
initiateLine();
stateOfClick = 1;
} else {
endLine();
}
}
<body>
<input type="text" id="test" onclick="createlines()">
</body>
A couple of things,
createlines()
to createLines
(camel-case).<element>.innerHtml
to <element>.value
createLines
won't be global which it needs to be for the onclick
to work.Here's a working example.