Code:
<input type = "button" id = "btn" value= "Add Student Data" onclick="getData(this.form)">
...
<script type="text/javascript">
function getData( form )
{
var temp = [ form.name.value, form.mark1.value, form.mark2.value,
form.mark3.value, form.mark4.value ];
var stringData = temp.join( "\n" );
// ... but what you will do with it now you don't say ...
// as a PURE GUESS:
form.resultdata.value = stringData;
}
</script>
You may
temp.join( ) on whatever kind of separator(s) you want.
You could even produce CSV data thus:
Code:
var stringData = '"' + temp.join( '","' ) + '"';
Hard to guess what you really want from such vague specifications.