By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,385 Members | 1,767 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,385 IT Pros & Developers. It's quick & easy.

hiding-enabling text fields

P: n/a
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;
Jul 27 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Jul 27, 1:36 pm, Malinmore <tim.carri...@gmail.comwrote:
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.
Jul 27 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.