[Javascript] Replace element with another element on click

judah judah at drumbeatinsight.com
Wed Mar 23 14:39:41 CST 2005


What would you do if element A was a textarea and element B was an 
htmlarea? I was asked to help on a project recently for this very same 
thing. http://xinha.gogo.co.nz/cgi-bin/trac.cgi/ticket/74
I would prefer to use the display idea but that might cause more 
problems when the user submits the form. A clear cut solution would be 
to put everything back to the way it was.
Best Cookies,
Judah


Shawn Milo wrote:

>In this case, I like to put each object in a DIV, and play with the visibility.
>
>Shawn
>
>
>
>Use this:
>
>theObject.style.display = "none";
>or
>theObject.style.display = "block";
>
>
>Do whatever on the onchange() of the checkbox.
>
>Declare one of the objects like this in the HTML:
><div id=weeklyStart style="display:none;">
>put object here
></div>
>
>
>That way, one will be invisible by default.
>
>I have used this to have a retail sales report which has
>monthly, weekly, and daily views all on one page.  When you select
>'weekly,' for example, it makes the start/end week options appear, 
>and the month or day boxes disappear. You get the idea.
>
>Shawn
>
>
>
>On Wed, 23 Mar 2005 00:43:38 -0600, Peter Brunone <peter at brunone.com> wrote:
>  
>
>>        Well, the nice IE way is to use the outerHTML property and just
>>gut the whole thing (it's pretty fast, too).
>>
>>        If that's not an option, you could have both elements at the
>>same point in your code and alternately set their height and width to
>>0px (I tried display:none but Netscape 7 doesn't support it).
>>
>>Cheers,
>>
>>Peter
>>
>>-----Original Message-----
>>From: javascript-bounces at LaTech.edu On Behalf Of judah
>>
>>I was curious how to replace a element with another element when the
>>user clicks a checkbox. If checkbox is enabled then replace element A
>>with B (erase A). If checkbox is unchecked then replace element B with A
>>
>>(erase B).
>>
>>Best Regards,
>>Judah
>>
>>_______________________________________________
>>Javascript mailing list
>>Javascript at LaTech.edu
>>https://lists.LaTech.edu/mailman/listinfo/javascript
>>
>>    
>>
>
>
>  
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20050323/bbb027d6/attachment.htm>
-------------- next part --------------
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.8.0 - Release Date: 3/21/2005


More information about the Javascript mailing list