Solved

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

Posted on 2012-04-11
7
262 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
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!

 
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

756 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