1. Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

Javascript, one works but not the other.

Discussion in 'Programming & Webmastering' started by Anath, Nov 21, 2011.

  1. Anath New Member

    Joined:
    Jul 24, 2009
    Messages:
    479 (0.25/day)
    Thanks Received:
    63
    I am creating a web based form in html. Basically when the form loads the javascript has two drop down menus that are hidden. However, when the user checks a checkbox they become visible. The problem I am running into is that one of the checkboxes work perfect but the other check box doesn't. Below is snipets of the code.


    script:
    Code:
    <script type="text/javascript">
    function hiddenload(){
    {
    document.accountreqform.emailDrop.style.visibility="hidden";
    }
    {
    document.accountreqform.inforDrop.style.visibility="hidden";
    }
    }
    function inspectemailbox() {
    if (document.accountreqform.EmailCheckBox.checked) {
    document.accountreqform.emailDrop.style.visibility = 'visible'; 
    }
    if (document.accountreqform.EmailCheckBox.checked == false) {
    document.accountreqform.emailDrop.style.visibility = 'hidden'; 
    }
    function inspectinforbox() {
    if (document.accountreqform.InforCheckBox.checked) {
    document.accountreqform.inforDrop.style.visibility = 'visible'; 
    }
    if (document.accountreqform.InforCheckBox.checked == false) {
    document.accountreqform.inforDrop.style.visibility = 'hidden'; 
    }
    }
    }
    </script>
    email check box
    Code:
    <input id="EmailCheckBox" name="EmailCheckBox[]" type="checkbox" value="eMail" onClick="inspectemailbox()">
    email drop down
    Code:
    <select id="emailDrop" name="emailDrop">
    removed due to info
                            </select>
    infor check box
    Code:
    <input id="InforCheckBox" name="InforCheckBox[]" type="checkbox" value="Infor EAM Login" onClick="inspectinforbox()">
    infor drop down
    Code:
    <select id="inforDrop" name="inforDrop">
    removed due to info
                            </select>
    Like I said the email check box works perfectly. However, when I click the infor check box it does not make the infor drop down menu visible.
     
  2. digibucc

    digibucc

    Joined:
    May 21, 2009
    Messages:
    4,923 (2.49/day)
    Thanks Received:
    1,493
    i'm looking through, not positive atm.

    imo a much easier way would be to place them in divs, and set the divs to hidden via css. then just have onclick added to the checkbox that will set the div's visibility back.
     
    Anath says thanks.
  3. Anath New Member

    Joined:
    Jul 24, 2009
    Messages:
    479 (0.25/day)
    Thanks Received:
    63
    it had to do with the brackets. I changed each one to its own script and now it works. Thanks for your help digi
     
    digibucc says thanks.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guest)

Share This Page