Solved

I am trying to copy info from a group of coloumns to a next group of coloumns

Posted on 2012-04-11
7
263 Views
Last Modified: 2012-04-22
I am trying to copy info from a group of coloumns to a next group of coloumns using a check box. If the user uncheck the check box the coloumns that I copy to would be clear so the user can enter a differentset of info into the colounms.

this is a html form

1. How can I do this

2. what language should I use java script or php to do this

3. can I get some code example.
0
Comment
Question by:1030071002
[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
  • 3
  • 3
7 Comments
 
LVL 20

Assisted Solution

by:Proculopsis
Proculopsis earned 167 total points
ID: 37836408
Do you mean something like this jsfiddle.
0
 
LVL 9

Assisted Solution

by:Sar1973
Sar1973 earned 333 total points
ID: 37836991
If you have a table with rows and columns, you can use Javascript innerHTML or innerText function, combined with "onclick=setContentCB()" event associated to the checkbox and an if function which sets the content you want to display.
Here you got it:
function setContentCB() {
var myCheckName = ["CheckBox1", "CheckBox2", "......"];
var myContent = [["Content1C", "Content2C", "......"], ["Content1U", "Content2U", "......"]];
var myCheckBox;
      for (var k=0;k<myCheckName.length;k++) {
            myCheckBox = document.getElementsByName(myCheckName[k])[0];            if(myCheckBox.checked) {
            document.getElementById("myTable").rows[0].cells                        [k].innerHTML=myContent[0][k];
      } else {
            document.getElementById("myTable").rows[0].cells                        [k].innerHTML=myContent[1][k];
      }
      }
}
See also http://www.w3schools.com/js/tryit.asp?filename=try_dom_tablerow_cells.
0
 

Accepted Solution

by:
1030071002 earned 0 total points
ID: 37838315
Okay maybe I was not clear enough I want to copy the content from one group of colounms to a next group of colounms. Both group of colounms already exists on the form.
0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
LVL 9

Assisted Solution

by:Sar1973
Sar1973 earned 333 total points
ID: 37838694
What do you mean with "group of columns"...? You have, for example, 4+4 columns in one table and you want to:
A. copy 1 to 5, 2 to 6, 3 to 7, 4 to 8 in case "Checked";
B. copy 5 to 1, 6 to 2, 7 to 3, 8 to 4 in case "Unchecked" (even at the same time);
C. (other))
Please post some HTML code corresponding to the area you intend to modify; notice also that innerHTML function can be applied to many elements/tags, but the essential condition is that you have identified them with id="..." and/or name="..." attributes.
Then, replace "myTable" in the above example with the id of the element you want to apply.
If you have different columns in a table with 1 row each (row number 0), then apply to the C columns like this:
 if(myCheckBox.checked) {
        document.getElementById("myTable").rows[0].cells[0].innerHTML = myContent[0][k];
        ..........
        document.getElementById("myTable").rows[0].cells[C].innerHTML = myContent[0][k];
 } else {
        document.getElementById("myTable").rows[0].cells[0].innerHTML = myContent[1][k];
        ..........
        document.getElementById("myTable").rows[0].cells[C].innerHTML = myContent[1][k];
 }
or if you just want to exchange table contents:
if (....)
     document.getElementById("myTable").rows[0].cells[1].innerHTML = document.getElementById("myTable").rows[0].cells[0].outerHTML;
.......
     document.getElementById("myTable").rows[0].cells[C].innerHTML = document.getElementById("myTable").rows[0].cells[C-1].outerHTML;
....else
....
Notice with certain elements such as Text areas you can use inner/outerText instead.
0
 

Author Comment

by:1030071002
ID: 37856931
I had to pay some one to show me what to do.
0
 
LVL 9

Expert Comment

by:Sar1973
ID: 37857111
My solution seems clear enough: if your "group of columns" is a table with name/identified columns and/or cells, the code I have provided should work.
0
 

Author Closing Comment

by:1030071002
ID: 37877344
No solid example and solution
0

Featured Post

Independent Software Vendors: 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!

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
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…

752 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