Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

wierd behaviour when disabling an input field

Status
Not open for further replies.

1DMF

Programmer
Jan 18, 2005
8,795
GB
Hi,

Not sure if this is a JS question, I think it's more DOM related though, so here goes...

I have a form, on it is a drop down, I have an onchange, this checks the value of the drop down and disables some input fields depending on the select list value...HOWEVER...

When the JS 'object'.disabled = true; is issued, the fieldset the input field is wrapped in vanishes and all the other fields in the fieldset.

Why on earth is this happening, it's a members area so can't give access to it , but here is the code part in questions
....FORM....
Code:
                <                <fieldset class="Status">
                    <legend>Loan Type &amp; Status&nbsp;</legend>
                        <label for="loantype">Loan Type</label>
                        <select id="loantype" name="loantype" onchange="check_loan_type(this)";>
                                <option value="">Please Select</option>
                                
                                    <option value="Secured"  >Secured</option>
                                
                                    <option value="Unsecured"  >Unsecured</option>
                                
                                    <option value="Bridging"  >Bridging</option>
                                
                                    <option value="Commercial"  >Commercial</option>
                                                                
                        </select>                        
                        <label for="loanstatus" style="width:98px;">Status</label>
                        <select id="loanstatus" name="loanstatus" > 
                                <option value="">Please Select</option>
                                
                                    <option value="Full Status"  >Full Status</option>
                                
                                    <option value="Self Cert"  >Self Cert</option>
                                
                                    <option value="Fast Track"  >Fast Track</option>
                                   
                        </select>                      
                </fieldset>
                <fieldset class="Subs">
                    <legend>Regulation &amp; Submission Date&nbsp;</legend>
                        <label for="regulation">Regulation</label>
                        <select id="regulation" name="regulation" >
                                <option value="">Please Select</option>
                                
                                    <option value="FSA Regulated"  >FSA Regulated</option>
                                
                                    <option value="Non-Regulated"  >Non-Regulated</option>
                                                                
                        </select>                        
                        <label for="subdate" style="width:120px;">Sub Date</label><input id="subdate" type="text" name="subdate" value="" size="18" />                                             
                </fieldset> 
                <fieldset class="Scheme">
                    <legend>Scheme Details&nbsp;</legend>
                        <label for="lender" style="width:40px;">Lender</label>
                        <select id="lender" name="lender" onchange="check_lender(this);">
                                <option value="">Please Select</option>
                                    <option value="Abacus 
                                <option value="Other">Other</option>                   
                        </select> 
                        <label for="scheme" style="width:40px;">Scheme</label><input id="scheme" type="text" name="scheme" value="" size="15" />
                        <div id="olend" style="visibility:hidden; float:left;"><label for="otherlender" style="color:red; float:left;">Specify</label><input  style="width:330px;" id="otherlender" type="text" name="otherlender" value="" size="48" /></div>                           
                        <label for="clientnames" style="clear:left;">Client Names</label><input style="width:330px;" id="clientnames" type="text" name="clientnames" value="" size="48" />                      
                        <label for="clientaddress" style="padding-top:10px;">Address of Mortgaged Property</label><textarea  style="width:330px;" id="clientaddress" name="clientaddress" cols="" rows="5" ></textarea>
                        <label for="clientpostcode">Postcode</label><input id="clientpostcode" type="text" name="clientpostcode" size="10" value="" />
                        <label for="loanamount"  style="width:110px;">Loan Amount</label><input id="loanamount" type="text" name="loanamount" size="17" value="" onkeyup="isCurrency(loanamount,loanamount.value)" onblur="comBlur(this);" /> 
                        <label for="ltv">LTV %</label><input id="ltv" type="text" name="ltv" size="10" value="" onkeyup="isPerc(this); calc_property_value(this);" />
                        <label for="propertyvalue" style="width:110px;">Property Value</label><input id="propertyvalue" type="text" name="propertyvalue" size="17" value=""  onkeyup="isCurrency(propertyvalue,propertyvalue.value); calc_ltv(this);"  onblur="comBlur(this);" /> 
                        <div style="clear:both;">
                        <label for="term" >Term</label><input  id="term" type="text" name="term" value="" size="10" onkeyup="isNumber(term,term.value);" />                      
                        </div>
                        <div style="clear:both;">
                        <label for="subroute" >Sub Route</label>
                        <select id="subroute" name="subroute" onchange="sub_other(this);">
                                <option value="">Please Select</option>
                                
                                    <option value="Direct"  >Direct</option>
                                
                                    <option value="SMS"  >SMS</option>
                                
                                    <option value="TFC"  >TFC</option>
                                
                                    <option value="SLS"  >SLS</option>
                                
                                    <option value="L&G Exclusives"  >L&G Exclusives</option>
                                 
                                <option value="Other">Other</option>
                        </select>
                        <div id="osub" style="visibility:hidden;">
                            <label for="subother" style="width:55px; color:red;">Specify</label><input id="subother" type="text" name="subother" size="21" value="" />                  
                        </div>
                        </div>
                </fieldset>
.....JS FOR THE ONCHANGE.....
Code:
function check_loan_type(obj){
 
    var reg = document.getElementById('regulation');
    var ltv = document.getElementById('ltv');
    var pval = document.getElementById('propertyvalue');
    
    if(obj.value=='Bridging'){
        reg.disabled = false;
        ltv.disabled = false;
        pval.disabled = false;
        reg.options[0].selected = true;   
    }
    else {
        ltv.disabled = true;
        pval.disabled = true;        
        reg.disabled = true;   
        reg.options[2].selected = true; 
        pval.value = "";
        ltv.value = "";  
    }
              
    
}

the fieldset / ledgend "scheme" vanishes when ltv or propertyvalue is made disabled?

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
ok found the culprit, I actually had the form wrapped in a table (yeah I know!!!) , and for some reason this weird behaviour was happening.

Took the table away and all is working fine, now just got to jig my floated fieldsets around to get the correct order now the table has gone!



"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top