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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:05:53+00:00 2026-06-14T01:05:53+00:00

I created a drop down list in PHP and it’s selecting the last item

  • 0

I created a drop down list in PHP and it’s selecting the last item of the list and I can’t figure out why it’s doing this.

When I echo the event_id (the value that is returned), it’s the last item every time. The list is populated correctly.

$forms = mysql_query("select events.event_title, events.event_id, saved_forms.id from events
                     INNER JOIN saved_forms on saved_forms.id = events.event_id
                    where saved_forms.form_type = 'e' and events.event_by = '$my_username'");   

while($form = mysql_fetch_array($forms)){
    $form_id = $form['event_id'];
    $selection.="<OPTION VALUE=\"$form_id\">".$form['event_title']."</OPTION>";
}

?>
<div id="saved_forms">
<tr><td><select name ="saved_form" value ="<? echo $form_id; ?>" onchange="showUser(<? echo $form_id; ?>)">
<Option value="$form_id"><? echo $selection; ?></Select></td><td>Select Existing Form</td></tr>
</div>
  • 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-14T01:05:54+00:00Added an answer on June 14, 2026 at 1:05 am

    Your problem is here

    <select name="saved_form" value="<? echo $form_id; ?>" onchange="showUser(<? echo $form_id; ?>)">
    

    By giving the select tag a value of $form_id you have a high chance of overriding the value set in the options. And you shouldn’t hardcode the value into the onchange event. Try removing the value from select and let the option tags do the work.

    <select name="saved_form" onchange="showUser(this.value)">
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created and html form which have a drop down list. This drop
I have the following active drop down list <?php echo CHtml::activeDropDownList($project, 'city', CHtml::listData(City::model()->findAll(), 'id',
I created drop down list using java. But i am not aware of creating
I've created a very simple drop down list in excel. It holds a sequence
I need to create one drop down list contains some Languages. By selecting any
I created a drop down list(with javascript onchange features), I would like to rewrite
I have created a simple drop-down menu in PHP: <td> Privilege: </td> <td><select name=privilege>
I created 3 drop down list in my html. For the first drop down,
I have created an html form. it consist of several drop down list for
I have got 2 drop down list in my php form. Values in the

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.