hiding-enabling text fields

M

Malinmore

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;
 
C

C. (http://symcbean.blogspot.com/)

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top