Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8029487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:27:05+00:00 2026-06-05T00:27:05+00:00

The onblur handler is invoked, and the switch executed. Yet the specified elements remain

  • 0

The onblur handler is invoked, and the switch executed.
Yet the specified elements remain unchanged.

What is wrong in the attempt to set element style to ‘none’/’block’ in the HTML below using javascript?

<html>
  <head>
    <meta content="text/html; charset=windows-1252" http-equiv="Content-Type">
    <title>Randomage</title>
    <link rel="shortcut icon" href="//ssl.gstatic.com/docs/spreadsheets/forms/favicon_jfk.png" type="image/x-icon">
    <link href="http://spreadsheets.google.com/client/css/779923916-published_form_compiled.css" type="text/css" rel="stylesheet">
    <style type="text/css">@media print{@page {size:A5}body{padding:0;background-color:#fff}.ss-form-container{width:100%;border:none}}h2.ss-section-title{background-color:transparent}div.ss-submit div.ss-form-entry{background:none;border:none}</style>
  </head>
  <body class="ss-base-body" dir="ltr" itemscope=""
    itemtype="http://schema.org/CreativeWork/FormObject">    
    <h3>Please fill in the form below</h3>
    <br>
    <div class="ss-required-asterisk">* Required</div>
    <div class="ss-form">
      <form id="halfyly_edit">
        <div class="errorheader"><b>Looks like you have a question or two that still needs to be filled out.</b></div>
        <table style=" text-align: left; width: 75%;" border="0" cellpadding="2" cellspacing="2">
          <tbody>
            <tr>  
              <td style="align:center;"><br>
                <div class="errorbox-bad">
                  <div class="ss-item ss-item-required ss-select">
                    <div class="ss-form-entry"> <label
                        class="ss-q-title" for="entry_16">Options <span class="ss-required-asterisk">*</span></label>
                      <label class="ss-q-help" for="entry_16"></label>
                      <select name="entry.16.single" id="entry_16" onblur="doSelect();">
                        <option value="sel0">Select 0</option>
                        <option value="sel1">Select 1</option>
                      </select>
                    </div>
                  </div>
                </div>
              </td>
              <td style="align:center;" >
                <div class="errorbox-good" id="entry_17_div"> <br>
                  <div class="ss-item ss-text">
                    <div class="ss-form-entry"> <label
                        class="ss-q-title" for="entry_17">Option 0
                      </label> <label class="ss-q-help" for="entry_17">A quick brown fox jumps over the lazy dog</label> <input name="entry.17.single"
                        value="" class="ss-q-short" id="entry_17"
                        type="text"> 
                    </div>
                  </div>
                </div>
               </td>
              <td style="align:center;">
                <div class="errorbox-good" id="entry_18_div"> <br>
                  <div class="ss-item ss-text">
                    <div class="ss-form-entry"> <label
                        class="ss-q-title" for="entry_18">Option 1</label> <label class="ss-q-help"
                        for="entry_18">The quick brown dog jumps over a lazy fox</label> <input
                        name="entry.18.single" value=""
                        class="ss-q-short" id="entry_18" type="text"> 
                    </div>
                  </div>
                </div>
              </td>
            </tr>
            <tr>
              <td> 
                    <input name="pageNumber" value="" type="hidden"> 
                    <input name="backupCache" value="" type="hidden">
                <div class="ss-item ss-navigate">
                  <div class="ss-form-entry"> 
                    <input name="submit" value="Submit" type="submit" disabled> 
                  </div>
                </div>
              </td>
            </tr>

          </tbody>
        </table>
      </form>
  </div>
  <script type="text/javascript">
        function doSelect(){

                var entry_16 = document.getElementById('entry_16');                

                switch( entry_16.selectedIndex ){


                case 0: 
                    // Option 0
                    document.getElementyById('entry_18_div').style.display = "none";                
                    document.getElementyById('entry_17_div').style.display = "block";
                    break;
                case 1:
                    // Option 1
                    document.getElementyById('entry_18_div').style.display = "block";
                    document.getElementyById('entry_17_div').style.display = "none";
                    break;
                }
        }

  </script>
</body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T00:27:08+00:00Added an answer on June 5, 2026 at 12:27 am

    You have 4 typo’s: getElementyById isn’t a default DOM element javascript method (doesn’t exist). Replace those by getElementById.

    Your function will be correctly executed in the onblur event then. JSFiddle

    I’d suggest calling it in the onchange event instead, if you want your page to be more dynamic. Example

    Also, check your Javascript console (Chrome/IE: F12, Firefox: Ctrl+Shift+K) when testing your code. 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was thinking of forcing an onblur handler to run by calling the element's
I am looking to validate a form element using ajax validation using the OnBlur
I have an onclick handler for a button. When user clicks on it onBlur()
How to call a C# function on the onblur event of the listbox ?
I am currently executing AJAX query stores on each onblur if this.value is not
I want to do a Date Check on a TextBox with a onBlur event.
Using jQuery validation - validating on blur: $('input, select, radio, checkbox').blur(function(){ $(#createAccount).validate().element(this); }); If
I have text input element and an event is fired on blur event and
What's the correct syntax for an HTML helper (in MVC2) to define an onblur
In my master page i've a textbox. <asp:TextBox ID=SearchTextBox runat=server class=searchtxtbox onfocus=HideSearchWaterMark(); Text=Search onblur=ShowSearchWaterMark(this);

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.