<script src="jquery.js"></script>
<script>
function saveScore (score) {
score=document.input.$('.inputright').value
$('submit').click(function(event) {
$('<div>')
.append(score)
.appendTo('.wincolumn');
});
}
</script>
</head>
<body>
<form name= "myform">
<input class="inputright" type="text" value="Team?" onfocus='value=""' onblur="value='Team?'" onclick="saveScore(score)">
</form>
<div id="bottomcontainer">
<div class="personalcolumns" id="niccolumn">
<div class="playername"> Nic Meiring </div>
<div class="wincolumn WLRcolumn"> </div>
<div class="losscolumn WLRcolumn"> </div>
<div class="resultcolumn WLRcolumn"> </div>
</div>
</body>
I want to take the input in the text field called Team? and write it to the column with the class .teamcolumn
2 main problems(I think)
- allowing the text field to have a default value of “Team?” but then switching its value to the input when the
onclickmethod is called (and therefore the function is called) - how to best write to the document from within that function.
document.writeln()maybe?
Thanks
I created a demo for you at jsFiddle. The input field defaults to “Team?” if no text is entered, however if text is entered then it is not changed. If the input field loses focus and it is empty, it returns to “Team?”. Once the field is blurred the value (if not “Team?”) is then appended to the .wincolumn div. I removed your savescore function and all your inline event handlers.
jQuery:
HTML: