SunQuest
 
           JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old August 26th, 2005, 04:30 AM
goangus goangus is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2005
Posts: 4 goangus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 36 m 57 sec
Reputation Power: 0
Changing html tags with a checkbox

Can someone help, I'm not overly familiar with javascript!! I want to have a field in a table that contains 1 text field if a checbox is checked, and 2 if its not.

I've tried using:
[code]
function PostFunction()
{
if (FrmRecipient.chkforces.checked)
{
FrmRecipient.postcodecell.innerHTML = '<input type="text" name="Postcode" size="25" maxlength=25 value="<%=Asp_Postcode%>" style="font-size:10px; font-family:verdana" onkeypress="return KPress()">';
}
}
[code]

but this tells me that postcodecell in null or not an object??
any suggestions greatly appreciated

Reply With Quote
  #2  
Old August 26th, 2005, 05:45 AM
MichaelSoft MichaelSoft is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2005
Location: The Netherlands
Posts: 121 MichaelSoft User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 h 20 sec
Reputation Power: 3
You'll have to give some of the HTML also.

I always create a page with all boxes needed, and hides the ones I don't want to see in run-time.

E.g. if you have the following HTML:
Code:
<input type='checkbox' id='checky' onclick="Show('input2');">
<input type='text'     id='input1'>
<input type='text'     id='input2'>


The this script will show or hide the input2 box:
Code:
function Show(EditID)
{
  // Check the DOM
  if(document.getElementById)
  {
    // Get the elements
    el_check = document.getElementById('checky');
    el_edit  = document.getElementById(EditID);
    
    // Check if they were found
    if(el_check && el_edit)
    {
      // Make editbox show when checked
      el_edit.style.display = el_check.checked ? '' : none;
    }
  }  
}


Not actually checked it agains errors, but the principle should work.
The big advantage is that the user can click the checkbox ON and OFF and ON, and the editbox will toggle with it.
The same principle can be used to show/hide a table row (<tr id='row2'>), a span, div etc., which enables you to put some text in front of the input box...

Reply With Quote
  #3  
Old August 26th, 2005, 06:14 AM
goangus goangus is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2005
Posts: 4 goangus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 36 m 57 sec
Reputation Power: 0
Thumbs up

thankyou, that helps a great deal!!!

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > Changing html tags with a checkbox


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway