i just want to create a simple script
i just want to display the value of what i selected radio button to the textbox
here's my code... TIA
<script>
function validateForm() {
//VALIDATIONS
var x = document.forms["myForm"]["ticket_no"].value.length===5;
if (x == null || x == "") {
alert("ticket_no must be filled out or must 5 numbers only");
return false;
}
var x = document.forms["myForm"]["school_name"].value;
if (x == null || x == "") {
alert("school_name must be filled out");
return false;
}
var x = document.forms["myForm"]["region"].value;
if (x == null || x == "") {
alert("region must be filled out");
return false;
}
var x = document.forms["myForm"]["municipality"].value;
if (x == null || x == "") {
alert("municipality must be filled out");
return false;
}
var x = document.forms["myForm"]["comment"].value;
if (x == null || x == "") {
alert("comment must be filled out");
return false;
}
}
</script>
</head>
<body>
<script>
function popitup() {
var w = 900;
var h = 800;
var left = (screen.width/2)-(w/2);
var top = (screen.height/2)-(h/2);
var newwindow2 = window.open('','','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+ top+', left='+left);
var tmp = newwindow2.document;
tmp.write('<html><head><title>Region Selection</title>');
tmp.write('<link rel="stylesheet" href="
js.css">');
tmp.write('</head><body><p>Select a Region.</p>');
tmp.write('<form name="myForm">');
tmp.write('<input type="radio" name="region" value="Region 1">Region 1<br>');
tmp.write('<input type="radio" name="region" value="Region 2">Region 1<br>');
tmp.write('<input type="button" onclick="myFunction()" value="Submit Region">');
tmp.write('</form>');
tmp.write('<p><a href="javascript
:self.close()">Close</a></p>');
tmp.write('</body></html>');
tmp.close();
}
</script>
<script>
function myFunction() {
var region = document.myForm[0];
var txt = "";
var i;
for (i = 0; i < region.length; i++) {
if (region[i].checked) {
txt = txt + region[i].value + " ";
}
}
document.myform.getElementById.value = text;
}
</script>
<form name="myForm" action="add_school.php" onSubmit="return validateForm()" method="post">
<table style="width:30%" border="0">
<tr>
<td><center>ticket_no: </center></td>
<td><input type="text" name="ticket_no"></td>
</tr>
<tr>
<td><center>school_name: </center></td>
<td><input type="text" name="school_name"></td>
<tr>
<td><center>region: </center></td>
<td> <input type="text" name="region" id="order">
<button type="button" onClick="popitup()">Select</button></td>
</tr>
<tr>
<td><center>assigned_to: </center></td>
<td><input type="text" name="assigned_to"></td>
</tr>
<tr>
<td><center>municipality: </center></td>
<td><input type="text" name="municipality"></td>
</tr>
<tr>
<td><center>comment: </center></td>
<td><textarea name='comment' id='comment'></textarea><br /></td>
</tr>
<tr>
<td><center><input type="submit" value="Submit"></center></td>
<td><input type="reset" value="Clear"></td>
</tr>
</table>
</form>