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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:37:45+00:00 2026-06-17T19:37:45+00:00

So I have a select in a form… <select id=aca name=aca> <option value=2012>2012-2013</option> <option

  • 0

So I have a select in a form…

<select id="aca" name="aca">
  <option value="2012">2012-2013</option>
  <option value="2011">2011-2012</option>
  <option value="2010">2010-2011</option>
  <option value="2009">2009-2010</option>
  <option value="2008">2008-2009</option>
  <option value="2007">2007-2008</option>
  <option value="2006">2006-2007</option>
  <option value="2005">2005-2006</option>
</select>

Looks good, right ? Then I want to check if the whole form is set:

if(isset($_FILES['fichier']) && isset($_POST['nom']) && isset($_POST['a']) && isset($_POST['c']) && isset($_POST['t']) && isset($_POST['auteur']) && isset($_POST['aca'])) echo 'tout';

Well this always return FALSE, and I know it’s due to ‘aca’. When I try…

if(isset($_POST['aca'])) echo 'aca';

It returns TRUE if I selected something in the list, and the other condition still doesn’t echo ‘tout’, so I just see ‘aca’. And this js line doesn’t seem to be the problem as other select’s return TRUE.

$("select").prop('selectedIndex', -1);

I really don’t understand… HALP ^^”

Full HTML:

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8" />
  <title>Upload</title>
  <link rel="stylesheet" href="style/upload.css"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="js/upload.js"></script>
</head>
<body>

<form method="post" action="" enctype="multipart/form-data">

<fieldset>
<legend>Informations d'upload</legend>
<p>Fichier (tous formats | max. 1 Mo):</p>
<input type="file" name="fichier" size="60"/><br/>
<p>Nom du fichier. Caractères utilisables: alphanumériques °*@()-_()</p>
<input type="text" name="nom" size="40"/>
</fieldset>

<fieldset>
<legend>Classification</legend>
<p>Merci d'indiquer où ce fichier devra être classé.</p>
  <select id="a" name="a">
    <option value="0">BA1</option>
  </select>
  <select id="c" name="c" style="display:none"></select>
  <select id="t" name="t" style="display:none"></select>
</fieldset>

<fieldset>
<legend>Détails</legend>
<p>Auteur:</p>
<input type="text" name="auteur" size="40"/>
<p>Année académique:</p>
<select id="aca" name="aca">
  <option value="2012">2012-2013</option>
  <option value="2011">2011-2012</option>
  <option value="2010">2010-2011</option>
  <option value="2009">2009-2010</option>
  <option value="2008">2008-2009</option>
  <option value="2007">2007-2008</option>
  <option value="2006">2006-2007</option>
  <option value="2005">2005-2006</option>
</select>
</fieldset>

<br/>

<div style="width:500px;text-align:center">
<input type="submit" name="submit" value="Envoyer" />
</div>

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

Full PHP:

<?php
$formats = array('pdf');
echo strtolower(substr(strrchr($_FILES['fichier']['name'],'.'),1)).'<br/>';
if(isset($_POST['aca'])) echo 'aca';
if(isset($_FILES['fichier']) && isset($_POST['nom']) && isset($_POST['a']) && isset($_POST['c']) && isset($_POST['t']) && isset($_POST['auteur']) && isset($_POST['aca'])) echo 'tout';
if(preg_match("#^[a-zA-Z0-9éè°*@ ()_-]{10,50}$#",$_POST['nom']))
{
echo 'OK';
}
else echo 'Nope';
?>
  • 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-17T19:37:46+00:00Added an answer on June 17, 2026 at 7:37 pm

    If nothing is selected, the element doesn’t POST to the server. You can fix this by making the select:

    <select id="aca" name="aca">
      <option value="" selected="selected"> </option>
      <option value="2012">2012-2013</option>
      <option value="2011">2011-2012</option>
      <option value="2010">2010-2011</option>
      <option value="2009">2009-2010</option>
      <option value="2008">2008-2009</option>
      <option value="2007">2007-2008</option>
      <option value="2006">2006-2007</option>
      <option value="2005">2005-2006</option>
    </select>
    

    And again, you must do this for the other “select” elements if you want them to POST without selecting something.

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

Sidebar

Related Questions

I have a select form filled with following data: <select id=attachments[32][color][] name=attachments[32][color][]> <option value=>--
I have a select list: <select name=taxonomy[1][] multiple=multiple class=form-select id=edit-taxonomy-1 size=7> <option value=0>None</option> <option
I have this form select: <select name=select_date id=select_date> <optgroup label=Select Date> <option value=0 selected=selected>Custom
The select form component in grails can have the form: <g:select name=user.age from=${0..59} value=${age}
I have a select options form fields setup like below: <select name=options[] multiple=multiple> <option
I have a select list like such: <select name=taxonomy[1][] multiple=multiple class=form-select id=edit-taxonomy-1 size=7> <option
I have a super basic HTML select form field - <select> <option value='1'>1</option> <option
I have a select form element with 5 options. If option 2 is selected
I have a select form with different options. I want to get the value
I have a form select statement, like this: = f.select :country_id, @countries.map{ |c| [c.name,

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.