Kevin
02-13-2003, 08:46 PM
Doing some basic work with forms and there values.
I think I have a good start here but keep running into the same errors. object dosent exist.
Can you take a look and advise?
I don't mean the entire form at once, of course time permitting:)
that would be great. But if you could take a look at say the radio group and the check boxes that would be great.
insight always appreciated
Thank You
Kevin
http://home.ix.netcom.com/~krr/frameA.html
The code
*******
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript">
<!--
function checkFormFields ()
{
function getRadio ()
{
var RadioValue = 0;
var n = RadioBtn.length;
if (n)
{
for (var i=0; i<n; i++)
{
if (RadioBtn[i].checked)
{
RadioValue = RadioBtn[i].value;
break;
} /* if */
} /* for */
} /* if */
} /* end getRadio */
function ChkBoxState ()
{
if(chkbx1.checked)
chk1 = chkbx1.value;
if(chkbx2.checked)
chk2 = chkbx2.value;
if (chkbx3.checked)
chk3 = chkbx3.value;
} /* end ChkBoxState() */
function GetSelected ()
{
var SelectList = document.form.SelectList;
var counter;
var curIndex;
for (counter = 0; counter < SelectList.options.length; counter++)
{
if (SelectList.options[counter].selected)
mySelected = document.form.SelectList.options[counter].index;
} /* for */
} /* GetSelected() */
var myTextField = document.form.textfield.value;
var myTextArea = document.form.TextArea.value;
var MyString= RadioValue + " is selected.<br><br>"
MyString += chk1 + " is selected.<br>"
MyString += chk2 + " is selected.<br>"
MyString += chk3 + " is selected.<br><br>"
MyString += mySelected + " is selected<br><br>"
MyString += myTextField + " is in the input text box.<br><br>"
MyString += myTextArea + " is in the text area box.<br><br>"
parent.fraB.document.write (MyString);
parent.fraB.document.close();
} /* end CheckFormFields() */
//-->
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<h1 align="center">Frames and Forms </h1>
<form>
<p>
<input type="radio" name="RadioBtn" value="Radio 1">Radio1<br>
<input type="radio" name="RadioBtn" value="Radio 2">Radio2<br>
<input type="radio" name="RadioBtn" value="Radio 3">Radio3
</p>
<p>
<input type="checkbox" name="chkbx1">Check1<br>
<input type="checkbox" name="chkbx2">Check2<br>
<input type="checkbox" name="chkbx3">Check3
</p>
<p>Select One
<select name="SelectList">
<option value="Select1" selected> Select1 </option>
<option value="Select2"> Select2 </option>
<option value="Select3"> Select3 </option>
<option value="Select4"> Select4 </option>
<option value="Select5"> Select5 </option>
</select>
</p>
<p>A few words
<input type="text" name="textfield" value="default text">
</p>
<p>
<textarea name="TextArea" cols="50" rows="6">word
word a
word b
word c
word d
</textarea>
</p>
<p>
<input type="button" value="Show Selections" onClick="checkFormFields(this.form)"; name="show">
</p>
<p>
<input type="reset" name="Reset" value="Reset form">
<br>
</p>
</form>
<h1 align="left"> </h1>
</body>
</html>
I think I have a good start here but keep running into the same errors. object dosent exist.
Can you take a look and advise?
I don't mean the entire form at once, of course time permitting:)
that would be great. But if you could take a look at say the radio group and the check boxes that would be great.
insight always appreciated
Thank You
Kevin
http://home.ix.netcom.com/~krr/frameA.html
The code
*******
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript">
<!--
function checkFormFields ()
{
function getRadio ()
{
var RadioValue = 0;
var n = RadioBtn.length;
if (n)
{
for (var i=0; i<n; i++)
{
if (RadioBtn[i].checked)
{
RadioValue = RadioBtn[i].value;
break;
} /* if */
} /* for */
} /* if */
} /* end getRadio */
function ChkBoxState ()
{
if(chkbx1.checked)
chk1 = chkbx1.value;
if(chkbx2.checked)
chk2 = chkbx2.value;
if (chkbx3.checked)
chk3 = chkbx3.value;
} /* end ChkBoxState() */
function GetSelected ()
{
var SelectList = document.form.SelectList;
var counter;
var curIndex;
for (counter = 0; counter < SelectList.options.length; counter++)
{
if (SelectList.options[counter].selected)
mySelected = document.form.SelectList.options[counter].index;
} /* for */
} /* GetSelected() */
var myTextField = document.form.textfield.value;
var myTextArea = document.form.TextArea.value;
var MyString= RadioValue + " is selected.<br><br>"
MyString += chk1 + " is selected.<br>"
MyString += chk2 + " is selected.<br>"
MyString += chk3 + " is selected.<br><br>"
MyString += mySelected + " is selected<br><br>"
MyString += myTextField + " is in the input text box.<br><br>"
MyString += myTextArea + " is in the text area box.<br><br>"
parent.fraB.document.write (MyString);
parent.fraB.document.close();
} /* end CheckFormFields() */
//-->
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<h1 align="center">Frames and Forms </h1>
<form>
<p>
<input type="radio" name="RadioBtn" value="Radio 1">Radio1<br>
<input type="radio" name="RadioBtn" value="Radio 2">Radio2<br>
<input type="radio" name="RadioBtn" value="Radio 3">Radio3
</p>
<p>
<input type="checkbox" name="chkbx1">Check1<br>
<input type="checkbox" name="chkbx2">Check2<br>
<input type="checkbox" name="chkbx3">Check3
</p>
<p>Select One
<select name="SelectList">
<option value="Select1" selected> Select1 </option>
<option value="Select2"> Select2 </option>
<option value="Select3"> Select3 </option>
<option value="Select4"> Select4 </option>
<option value="Select5"> Select5 </option>
</select>
</p>
<p>A few words
<input type="text" name="textfield" value="default text">
</p>
<p>
<textarea name="TextArea" cols="50" rows="6">word
word a
word b
word c
word d
</textarea>
</p>
<p>
<input type="button" value="Show Selections" onClick="checkFormFields(this.form)"; name="show">
</p>
<p>
<input type="reset" name="Reset" value="Reset form">
<br>
</p>
</form>
<h1 align="left"> </h1>
</body>
</html>