2 Replies - 5749 Views - Last Post: 12 September 2006 - 09:26 AM

#1 bukaida  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 11-September 06

Cannot display the checkbox and dropdown value using java script

Post icon  Posted 11 September 2006 - 05:00 AM

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
	<title>Form Information display using Java Script</title>
	<script language="Javascript" type="text/javascript">
	

	function myfunc()
	{
	x=document.f1.t1.value;
	y=document.f1.ad.value;
	z=document.f1.ph.value;
	for(count=0;count<2;count++)
	{
	if(document.f1.m1[count].checked)
	break;
	}
	if(count==0)
	   gen="Male";
	else
	   gen="Female";  
	
	document.write("<html><head><title>Submitted information</title></head>")
	document.write("<body bgcolor=\"#008080\" text=\"#800000\">")
	document.write("<h1>You have submitted the following informations</h1><hr>")
	document.write("Your name is:<b><font color=\"#FFFFFF\">"+x+"</font></b><br>");
	document.write("Your address is:<b><font color=\"#FFFFFF\">"+y+"</font></b><br>");
	document.write("Your Phone number is:<b><font color=\"#FFFFFF\">"+z+"</font></b><br>");
	document.write("Your Gender is:<b><font color=\"#FFFFFF\">"+gen+"</font></b><br>");
	/*document.write("Your Date of Birth is:<b><font color=\"#FFFFFF\">");
	mydd = document.f1.dd.value;
	document.write(+mydd);
	document.write("</font></b><br>")*/
	document.write("Your Hobbies are:<b><font color=\"#FFFFFF\">");
	for(i=0;i<4;i++)
	{
	if(document.f1.mycheck[i].checked) 
								{
								user_input = document.f1.mycheck[i].value;
								document.write("<b><font color=\"#FFFFFF\">"+user_input+"</font></b>");
								}
	}
		
	document.write("<br>");
	document.write("</body>")
	document.write("</html>")
	}
	
	function checkAll(){
	for (var i=0;i<document.forms[0].elements.length;i++)
	{
		var e=document.forms[0].elements[i];
		if ((e.name != 'all') && (e.type=='checkbox'))
		{
			e.checked=document.forms[0].all.checked;
		}
	}
}

</script>
</head>

<body bgcolor="#C0C0C0" text="#0000FF">
<div align="center"><H1>PERSONAL INFORMATION DETAILS<hr></H1></div>
<form name="f1" target="_self" onsubmit="myfunc()">
<table align="center" bgcolor="#808000">
<tr><td>Name:</td><td><input type="text" name="t1"></td></tr>
<tr><td><br></td></tr>
<tr><td>Address:</td><td><textarea cols="" rows="" name="ad"></textarea></td></tr>
<tr><td><br></td></tr>
<tr><td>Phone:</td><td><input type="text" name="ph" maxlength="11"></td></tr>
<tr><td><br></td></tr>
<tr><td>Gender:</td><td>Male<input type="radio" name="m1" value="male" checked>Female<input type="radio" name="m1" value="female"></td></tr>
<tr><td><br></td></tr>
<tr><td>DOB:</td><td><select name="dd">
	<option value="1" SELECTED>DD</option>
	<option value="2">1</option>
	<option value="3">2</option>
	<option value="4">3</option>
	<option value="5">4</option>
	<option value="6">5</option>
	<option value="7">6</option>
	<option value="8">7</option>
	<option value="9">8</option>
	<option value="10">9</option>
	<option value="11">10</option>
	<option value="12">11</option>
	<option value="13">12</option>
	<option value="14">13</option>
	<option value="15">14</option>
	<option value="16">15</option>
	<option value="17">16</option>
	<option value="18">17</option>
	<option value="19">18</option>
	<option value="20">19</option>
	<option value="21">20</option>
	<option value="22">21</option>
	<option value="23">22</option>
	<option value="24">23</option>
	<option value="25">24</option>
	<option value="26">25</option>
	<option value="27">26</option>
	<option value="28">27</option>
	<option value="29">28</option>
	<option value="30">29</option>
	<option value="31">30</option>
	<option value="32">31</option>
</select><select name="mm">
	<option value="1" SELECTED>MM</option>
	<option value="2">JAN</option>
	<option value="3">FEB</option>
	<option value="4">MAR</option>
	<option value="5">APR</option>
	<option value="6">MAY</option>
	<option value="7">JUNE</option>
	<option value="8">JULY</option>
	<option value="9">AUG</option>
	<option value="10">SEPT</option>
	<option value="11">OCT</option>
	<option value="12">NOV</option>
	<option value="13">DEC</option>
</select><select name="yy">
	<option value="1" SELECTED>YY</option>
	<option value="2">1982</option>
	<option value="3">1981</option>
	<option value="4">1980</option>
	<option value="5">1979</option>
	<option value="6">1978</option>
	<option value="7">1977</option>
	<option value="8">1976</option>
	<option value="9">1975</option>
	<option value="10">1974</option>
</select></td>
</tr>
<tr><td><br></td></tr>
<tr><td>Hobbies:</td><td><input type="checkbox" name="mycheck" value="Reading">Reading<input type="checkbox" name="mycheck" value="Listening music" >Listening music</td><td> <input type="checkbox" name="mycheck" value="Games">Games </td> <td><input type="checkbox" name="mycheck" value="Movies" >Movies </td> <td><input type="checkbox" name="all" value="Others" onclick="checkAll();">All of them.</td></tr>
<tr><td><br><br></td></tr>
</table>
<div align="center"><input type="submit" value="Enter information"></div>
</form>
</body>
</html>


Showing the error document.f1.mycheck is null or not an object. Same problem with drop down. Please help.

This post has been edited by bukaida: 11 September 2006 - 05:05 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Cannot display the checkbox and dropdown value using java script

#2 quim  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 18
  • View blog
  • Posts: 182
  • Joined: 11-December 05

Re: Cannot display the checkbox and dropdown value using java script

Posted 11 September 2006 - 06:34 AM

I view this page with IE7 and FireFox and it didnt show me any error
Was This Post Helpful? 0
  • +
  • -

#3 bukaida  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 11-September 06

Re: Cannot display the checkbox and dropdown value using java script

Post icon  Posted 12 September 2006 - 09:26 AM

Viewing in external browser will not show any error but it will not work(Display value of checkbox or dropdown)either. I have used Homesite 5.5 and inside the coding window, there is a browse option. Clicking it will show you the error and the line in which the error exists.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1