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:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old August 25th, 2005, 09:29 AM
JUANVAN JUANVAN is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2005
Posts: 2 JUANVAN User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 41 m 15 sec
Reputation Power: 0
Question Function Object passed to object...

function MakeReadOnlyBox(form, CBox, Box){
if(form.CBox.checked == true) {
form.CBox.checked = true;
form.Box.readOnly = !form.Box.readOnly;
}

if(form.+CBox+.checked == false) {
form.+CBox+.checked = false;
form.+Box+.readOnly = !form.+Box+.readOnly;
}
}

onClick="MakeReadOnlyBox(this.form,'CBookValue','BookValue' );"

Error - this.form.Cbox - Not an Object
How do you pass strings to and object in a function.. Sounds weird saying it..

Reply With Quote
  #2  
Old August 26th, 2005, 05:32 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
I would suggest that you use the DOM model. This is much mote browser independed.

Make sure that your checkbox and editbox have an appropriate id assigned to them e.g.:
Code:
<input type='input'       id='edit_id' readonly='readonly'/>


Then the following principle would work
Code:

<input type='checkbox' id='check_id' onclick="MakeReadOnlyBox('check_id', 'edit_id');"/>


function MakeReadOnlyBox(CheckID, EditID)
{
  // Check the DOM
  if(document.getElementById)
  {
    // Get the elements
    el_check = document.getElementById(CheckID);
    el_edit  = document.getElementById(EditID);
    
    // Check if they were found
    if(el_check && el_edit)
    {
      // Make editbox readonly when not checked
      el_edit.readonly = !el_check.checked;
    }
  }  
}

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > Function Object passed to object...


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 2 hosted by Hostway