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

  • SEARCH
  • Home
  • 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 8820115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:31:42+00:00 2026-06-14T05:31:42+00:00

I have two select blocks in my html form: <select id=select1> <option>1</option> <option>2</option> <option>3</option>

  • 0

I have two select blocks in my html form:

<select id="select1">
<option>1</option>
<option>2</option>
<option>3</option>
</select>

<select id="select2" onchange="someFunc()">
<option>A/option>
<option>B</option>
</select>

I have a validateForm() function called from the form tag @onSubmit. the “someFunc” function populates some innerHTML elsewhere in the form. The issue I’m having, is that when I hit submit, the value of select1 reverts to its original default value, and the validateForm function fails.

the someFunc function is really long, so I didn’t post the whole thing, but essentially what it does is check a string value and populate html, like:

if(select2.value = 'A'){
     document.getElementById('anotherElement').innerHTML= '<h1>a new tag</h1>';
}

is there another att besides @onChange?

Ok, here is a complete html form that describes the problem I am having:

<html>
<head>
<title>javascript q</title>
<script>
    function updateTag(){
document.getElementById('newHeading').innerHTML='<p     id="status">updated</p>';

    }


    function validateForm(){
        var s1 = document.getElementById('select1');
        var s2 = document.getElementById('select2');

        if( s1.value = 'please select' ){
                alert('please select a value from the pulldown');
                return false;
            }

        // updated html needs to have been performed and value selected
        if(document.getElementById('status') == null ){
                alert('status does not exist');
            }

    }

</script>

</head>
<body>

<h1>Javascript Q</h1>

<form id="testForm" onSubmit="return validateForm();">

<select id="select1">
    <option>please select</option>
    <option>1</option>
    <option>2</option>
    <option>3</option>
</select>

<select id="select2" onchange="updateTag()">
    <option>please select</option>
    <option>a</option>
    <option>b</option>
    <option>c</option>
</select>
<input type="submit" value="submit"/>       
<div id="newHeading">

</div>


</form>
</body>
</html>

what happens is, I select a value from each pulldown, hit submit, then the value of select1 reverts to its orig val, and fails the validation

hope that’s better.

thanks,
bp

  • 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-14T05:31:44+00:00Added an answer on June 14, 2026 at 5:31 am

    mea culpa, totally stupid oversight on my part

    if( s1.value = 'please select' ){
    

    should be

    if( s1.value == 'please select' ){
    

    sorry for stupid oversight

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

Sidebar

Related Questions

I have two select fields in a form. Every time one of these select
I have two select elements, A and B: when A's selected option changes, B's
I have two identical select boxes (aside from their names, of course), and I
So I have two multiple select boxes like this <select id=foo multiple=multiple> <option value=1>Option
I have two select boxes like so: <select id=one> <option value=default>Select File</option> <option value=path/to/file1>File
I have two select menus (#id1 and #id2) that, when validated as containing a
I have two select queries to use in my project for getting data and
I have two select boxes with dates. See here the jsfiddle: http://jsfiddle.net/egrba/ The people
I have two select lists, I would like jquery to either remove or disable
i have two select using as a dropdownlist for country/state everything works as i

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.