Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > hiding-enabling text fields

Reply
Thread Tools

hiding-enabling text fields

 
 
Malinmore
Guest
Posts: n/a
 
      07-27-2008
the following works well regarding one select box with one hidden text
box. however I need two unique select boxes with relevant hidden text
boxes that un-hide when the Add New option is selected. the problem is
that the upper hidden text box always appears when the page is loaded.
Can anyone tells me why?

//physicianID

function enableOtherPhysicians()
{
if (!document.getElementById) return;

var s1 = document.getElementById('referpersonID');
if (!s1) return;
if (s1.options[s1.selectedIndex].value != 'referpersonID') return;
var t1 = document.getElementById('referpersonIDnew');
var d1 = document.getElementById('delete1');
if (!t1) return;
t1.disabled = false;
t1.className = '';
d1.disabled = true;
d1.className = '';

var s3 = document.getElementById('physicianID');
if (!s3) return;
if (s3.options[s3.selectedIndex].value != 'physicianID') return;
var t3 = document.getElementById('physicianIDnew');
var d3 = document.getElementById('delete3');
if (!t3) return;
t3.disabled = false;
t3.className = '';
d3.disabled = true;
d3.classname = '';
}

function initPhysicians()
{
if (!document.getElementById) return;

var s1 = document.getElementById('referpersonID');
if (!s1) return;
s1.onchange = enableOtherPhysicians;
var t1 = document.getElementById('referpersonIDnew');
var d1 = document.getElementById('delete1');
if (!t1) return;
t1.disabled = true;
t1.className = 'person_hidden';
d1.disabled = false;
d1.className = 'person_hidden';

var s3 = document.getElementById('physicianID');
if (!s3) return;
s3.onchange = enableOtherPhysicians;
var t3 = document.getElementById('physicianIDnew');
var d3 = document.getElementById('delete3');
if (!t3) return;
t3.disabled = true;
t3.className = 'physician_hidden';
d3.disabled = false;
d3.classname = 'physician_hidden';
}

window.onload = initPhysicians;
 
Reply With Quote
 
 
 
 
C. (http://symcbean.blogspot.com/)
Guest
Posts: n/a
 
      07-27-2008
On Jul 27, 1:36 pm, Malinmore <(E-Mail Removed)> wrote:
> the following works well regarding one select box with one hidden text
> box. however I need two unique select boxes with relevant hidden text
> boxes that un-hide when the Add New option is selected. the problem is
> that the upper hidden text box always appears when the page is loaded.
> Can anyone tells me why?


No because your description relates to the position of the elements
while the code operates on their IDs. Your code is badly written and
you don't appear to have made any effort at diagnosing the fault
yourself.

You might want to
1) see if you are getting any javascript errors at runtime
2) try somethnig along the lines of:

function initPhysicians()
{
alert("initPhysicians() started");
if (!document.getElementById) {
alert("No document.getElementByID method");
return false;
}

var s1 = document.getElementById('referpersonID');
if (s1) {
s1.onchange = enableOtherPhysicians;
} else {
alert("referpersonID not found");
return false;
}
var t1 = document.getElementById('referpersonIDnew');
if (t1) {
t1.disabled = true;
t1.className = 'person_hidden';
} else {
alert("referpersonIDnew not found");
return false;
}
var d1 = document.getElementById('delete1');
....

C.
 
Reply With Quote
 
 
 
Reply

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
epydoc: How to add new fields as the building fields? Cyril.Liu Python 0 12-02-2008 05:01 AM
print struct fields and its member structs' fields recursively, generically call_me_anything C++ 4 09-30-2007 10:12 PM
Newbie - Reading a file with delimited fields, storing first two fields in a hash AMT2K5 Perl Misc 1 11-08-2005 01:06 AM
how to copy from fields to other fields middletree ASP General 1 11-05-2003 06:24 PM
Netscape hidden fields - array - multiple fields with same name mark.reichman@rl.af.mil Javascript 0 07-17-2003 03:05 PM



Advertisments