about checkbox

  • dummyagain
  • Born
  • Born
  • dummyagain
  • Posts: 2

Post 3+ Months Ago

i am designing a page that contains a checkbox,
if the checkbox is checked, then it will show another column(the checkbox is placed under a table).... however, i don't really know how i can achieve this.....

here is my code:
<form name="form2" method="post" action="">
<input type="checkbox" name="checkbox" value="checkbox" onClick="???">
<font size="1">Display Photo(s) </font>


can anyone suggests me someone way to solve this, thanks
  • Tannu4u
  • Proficient
  • Proficient
  • User avatar
  • Posts: 480
  • Loc: India

Post 3+ Months Ago

i do not know much but u can use innertext property of the JAVASCRIPT to do this.U can get help on innertext property on the web.Sorry i am in a hurry.If i am able to fine the code i will put it here.Bye everyone.......
  • s15199d
  • Expert
  • Expert
  • User avatar
  • Posts: 524
  • Loc: NC, USA

Post 3+ Months Ago

Here's how I'd do it:

Code: [ Select ]
if(form.checkboxname.checked){
    document.write('<tr><td rowspan=X></td></tr>');
}else{
    return false;
}
  1. if(form.checkboxname.checked){
  2.     document.write('<tr><td rowspan=X></td></tr>');
  3. }else{
  4.     return false;
  5. }


Or course you'd have to put your column content in the string being written by "document.write". I just put a bank row in there to show you how it would look, and so that you would know you can put HTML tags in the string.
  • s15199d
  • Expert
  • Expert
  • User avatar
  • Posts: 524
  • Loc: NC, USA

Post 3+ Months Ago

Since you're new I'm not sure how much javascript you know. So, it may be vital to add...that this code would need to go b/t the head tags in script tags like this

Code: [ Select ]
<HTML>
<HEAD>
    <TITLE>DUMMY'S PAGE</TITLE>
<SCRIPT>
function validateCheckbox(){
 if(form.checkboxname.checked){
   document.write('<tr><td rowspan=X></td></tr>');
 }else{
   return false;
 }
}
</SCRIPT>
</HEAD>
  1. <HTML>
  2. <HEAD>
  3.     <TITLE>DUMMY'S PAGE</TITLE>
  4. <SCRIPT>
  5. function validateCheckbox(){
  6.  if(form.checkboxname.checked){
  7.    document.write('<tr><td rowspan=X></td></tr>');
  8.  }else{
  9.    return false;
  10.  }
  11. }
  12. </SCRIPT>
  13. </HEAD>



Then in the body of the page wherever you want you check box...
Code: [ Select ]
<INPUT type="checkbox" name=younameit value="" id="" onClick="validateCheckbox();">
  • RichB
  • Guru
  • Guru
  • User avatar
  • Posts: 1121
  • Loc: Boston

Post 3+ Months Ago

Is the hidden column already there in the code but you just want to show/hide it when the checkbox is clicked?

Example
  • dummyagain
  • Born
  • Born
  • dummyagain
  • Posts: 2

Post 3+ Months Ago

i have already got a table, but i would like to create an EXTRA column that i can control its appearance
  • RichB
  • Guru
  • Guru
  • User avatar
  • Posts: 1121
  • Loc: Boston

Post 3+ Months Ago

Well, the dom-2 spedification allows you to create new nodes, but it's somewhat complicated and requires a bit of practice. I just started looking at it recently myself, and here's what I came up with for adding a column to a table using dom-2 methods.

example

I was also able to do pretty much the same thing with innerHTML by using a pre-existing column that was empty and changing it's contents. This is a lot simpler but lacks the flexibility of creating and removing individual nodes on the fly.

example

Post Information

  • Total Posts in this topic: 7 posts
  • Users browsing this forum: No registered users and 82 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.