?
Solved

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

Posted on 2010-09-08
7
Medium Priority
?
394 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:Gurvinder Pal Singh
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
WordPress Tutorial 4: Recommended Plugins

Now that you have WordPress installed, understand the interface, and know how to install new parts, let’s take a look at our recommended plugins.

 
LVL 13

Accepted Solution

by:
ansudhindra earned 1800 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:Gurvinder Pal Singh
Gurvinder Pal Singh earned 200 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:Gurvinder Pal Singh
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

WordPress Tutorial 1: Installation & Setup

WordPress is a very popular option for running your web site and can be used to get your content online quickly for the world to see. This guide will walk you through installing the WordPress server software and the initial setup process.

Question has a verified solution.

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

Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
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…
Suggested Courses

765 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