Solved

Need some help with textfield, select menu and checkbox interaction.

Posted on 2010-09-08
7
392 Views
Last Modified: 2012-05-10
Everything is explained in the code window.

Thank you,

Brian
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<label>
		<input type="checkbox" name="checkbox" id="checkbox" />
</label>
If Checkbox is checked then the B field will automatically EQ the A field value and so on with C and D and E and F. Fields B, D and F will also be &quot;disabled&quot;. If the checkbox is unchecked then the values will remain the same but editable again.<br />
<br />
<br />
<table width="0" border="0" cellspacing="0" cellpadding="0">
		<tr>
				<td colspan="2"><label>
						A Field
										<input type="text" name="textfield" id="textfield" value="First Name" /> 
						B Field
				</label></td>
				<td width="155"><input type="text" name="textfield2" id="textfield2" /></td>
		</tr>
		<tr>
				<td colspan="2"><label> C Field
								<input type="text" name="textfield3" id="textfield3" value="First Name" />
						D Field </label></td>
				<td><input type="text" name="textfield3" id="textfield4" /></td>
		</tr>
		<tr>
				<td width="193">E Field 
						<label>
								<select name="select" id="select">
										<option value="1">A</option>
										<option value="2">B</option>
								</select>
				</label></td>
				<td width="118"> F Field</td>
				<td><select name="select2" id="select2">
						<option value="1">A</option>
						<option value="2">B</option>
				</select></td>
		</tr>
</table>

</body>
</html>

Open in new window

0
Comment
Question by:brihol44
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 5

Expert Comment

by:drakeshe
ID: 33633762
Need more input please...
0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 33633771
<<B field will automatically EQ the A field value >>
what does this means?
0
 
LVL 5

Expert Comment

by:drakeshe
ID: 33633792
Are you familiar with javascript or jquery?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 13

Accepted Solution

by:
ansudhindra earned 450 total points
ID: 33633796
Hi, try th following code, let me know in case of ny thing neede....
test1.html
0
 
LVL 40

Assisted Solution

by:gurvinder372
gurvinder372 earned 50 total points
ID: 33633833
try this code as well (assuming EQ means Equal :))
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script>
   function enableAndCopy(thisObj)
   {
      if ( thisObj.checked )
	  {
		document.getElementById("textfield2").disabled = true;
		document.getElementById("textfield2").value = document.getElementById("textfield1").value;
		document.getElementById("textfield4").disabled = true;
		document.getElementById("textfield2").disabled = document.getElementById("textfield3").value;
		document.getElementById("select2").disabled = true;
		document.getElementById("select2").value = document.getElementById("select1").value;
	  }
	  else
	  {
		document.getElementById("textfield2").disabled = false;
		document.getElementById("textfield4").disabled = false;
		document.getElementById("select2").disabled = false;
	  }
   }
</script>
</head>

<body>
<label>
		<input type="checkbox" name="checkbox" id="checkbox" onclick="enableAndCopy(this)"/>
</label>
If Checkbox is checked then the B field will automatically EQ the A field value and so on with C and D and E and F. Fields B, D and F will also be &quot;disabled&quot;. If the checkbox is unchecked then the values will remain the same but editable again.<br />
<br />
<br />
<table width="0" border="0" cellspacing="0" cellpadding="0">
		<tr>
				<td colspan="2"><label>
						A Field
										<input type="text" name="textfield" id="textfield" value="First Name" /> 
						B Field
				</label></td>
				<td width="155"><input type="text" name="textfield2" id="textfield2"  /></td>
		</tr>
		<tr>
				<td colspan="2"><label> C Field
								<input type="text" name="textfield3" id="textfield3" value="First Name" />
						D Field </label></td>
				<td><input type="text" name="textfield3" id="textfield4" /></td>
		</tr>
		<tr>
				<td width="193">E Field 
						<label>
								<select name="select" id="select">
										<option value="1">A</option>
										<option value="2">B</option>
								</select>
				</label></td>
				<td width="118"> F Field</td>
				<td><select name="select2" id="select2" >
						<option value="1">A</option>
						<option value="2">B</option>
				</select></td>
		</tr>
</table>

</body>
</html>

Open in new window

0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 33633844
Sorry, small change
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
	<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>Untitled Document</title>
	<script>
	   function enableAndCopy(thisObj)
	   {
		  if ( thisObj.checked )
		  {
			document.getElementById("textfield2").value = document.getElementById("textfield").value;
			document.getElementById("textfield2").disabled = true;
			document.getElementById("textfield4").value = document.getElementById("textfield3").value;
			document.getElementById("textfield4").disabled = true;
			document.getElementById("select2").value = document.getElementById("select1").value;
			document.getElementById("select2").disabled = true;
		  }
		  else
		  {
			document.getElementById("textfield2").disabled = false;
			document.getElementById("textfield4").disabled = false;
			document.getElementById("select2").disabled = false;
		  }
	   }
	</script>
	</head>

	<body>
	<label>
			<input type="checkbox" name="checkbox" id="checkbox" onclick="enableAndCopy(this)"/>
	</label>
	If Checkbox is checked then the B field will automatically EQ the A field value and so on with C and D and E and F. Fields B, D and F will also be &quot;disabled&quot;. If the checkbox is unchecked then the values will remain the same but editable again.<br />
	<br />
	<br />
	<table width="0" border="0" cellspacing="0" cellpadding="0">
			<tr>
					<td colspan="2"><label>
							A Field
											<input type="text" name="textfield" id="textfield" value="First Name" /> 
							B Field
					</label></td>
					<td width="155"><input type="text" name="textfield2" id="textfield2"  /></td>
			</tr>
			<tr>
					<td colspan="2"><label> C Field
									<input type="text" name="textfield3" id="textfield3" value="First Name" />
							D Field </label></td>
					<td><input type="text" name="textfield3" id="textfield4" /></td>
			</tr>
			<tr>
					<td width="193">E Field 
							<label>
									<select name="select" id="select">
											<option value="1">A</option>
											<option value="2">B</option>
									</select>
					</label></td>
					<td width="118"> F Field</td>
					<td><select name="select2" id="select2" >
							<option value="1">A</option>
							<option value="2">B</option>
					</select></td>
			</tr>
	</table>

	</body>
	</html>

Open in new window

0
 

Author Closing Comment

by:brihol44
ID: 33633920
Perfect! Thanks ansudhindra! gurvinder372 the select menu wasn't working as the same as the other textfields... just FYI... but almost working correctly.
0

Featured Post

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question