Solved

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

Posted on 2012-04-11
7
253 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
  • 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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Ajax control editor 4 36
Tracking Bouncebacks in PHPMailer 3 10
PHP JSON Clean up 5 10
inserting while loop results 2 7
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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.
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now