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 8277627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:44:28+00:00 2026-06-08T08:44:28+00:00

I have this form: <form action= method=post> <select name=weeks id=weeks> <option value=1>1</option> <option value=2>2</option>

  • 0

I have this form:

<form action="" method="post">
   <select name="weeks" id="weeks">
      <option value="1">1</option>
      <option value="2">2</option>
      <option value="3">3</option>
      <option value="4">4</option>
      <option value="5">5</option>
      <option value="6">6</option>
      <option value="7">7</option>
      <option value="8">8</option>
      <option value="9">9</option>
      <option value="10">10</option>
   </select>
<input type="submit" value="Submit" />
</form>

How do I set an option to selected when the form is reloaded? Such as if I select 6 it will be selected for option 6 on reload and then if I switch it to 2 it will have 2 selected on reload?

  • 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-08T08:44:30+00:00Added an answer on June 8, 2026 at 8:44 am

    if you want a persistent behavior you should save the selected state somewhere.

    you can save it on the server side (db or session) or on the client side (cookie or localStorage).

    in case of saving on the client side i suggest using HTML5’s localStorage so just save the selected index (or whatever you need) there and each time you need to reload the page just take the selected index from there and change the select.
    here’s a sample how to save and get a variable in the client side:

    function getFoo() {
      var foo = localStorage.getItem('foo');
      if (!foo) {
        setFoo([defaults value]);
        return getFoo();
      } else return foo;
    }
    
    function setFoo(foo) {
      localStorage.setItem('foo', foo);      
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple form like this: <form name=serachForm method=post action=/home/search> <input type=text name=searchText
I have this HTML: <form action='uploadhandle.php' method='POST' enctype=multipart/form-data> <input type='file' class='fileinput' id='photo1' name='photo1'> <input
i have this html <ul> <li><form action=# name=formName></li> <li><input type=text name=someName /></li> <li><input type=text
I have this form <form action= method=post enctype=multipart/form-data name=form1 id=form1> <tr> <td width=32% valign=top>&nbsp;&nbsp;&nbsp;<strong
I have form like this: <form method=POST action=<?php echo base_url() ?>admin/admin_search> <fieldset> <label for=nalozi>Nalozi</label><input
I have this form:- <form action=> <table border=0> <td colspan=2 class=instruction>Select your desired option
I have a form whose action is set to itself. I want it this
I am testing a form. It looks like: <form accept-charset=UTF-8 action=/the_action method=post> <select id=id
I have simple form like this which accepts only two values string action and
I have situation like this: user submits form with action='/pay' in '/pay' I have

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.