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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:27:28+00:00 2026-06-17T21:27:28+00:00

How to set selected=selected for the saved option array below. Thanks ! e.g <option

  • 0

How to set selected=”selected” for the saved option array below. Thanks !

e.g

<option value="Facebook">Facebook</option>
<option value="Twitter" selected="selected">Twitter</option>



<select name="'. $id .'['.$order.'][url]" id="'. $id .'['.$order.'][url]">

                $socialicons =  array ('facebook' => 'Facebook', 'twitter' => 'Twitter');

                foreach ($socialicons as $socialicon) {


             <option value="'.$socialicon.'" />'.$socialicon.'</option>

                }

             </select>
  • 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-17T21:27:29+00:00Added an answer on June 17, 2026 at 9:27 pm

    You will have the sent value in your POST array at $_POST[$id][$order]['url'] I think. Then it’s just a matter of comparing the sent value with the current value in the loop:

    foreach ($socialicons as $socialicon)  {
        $selected = '';
        if ($socialicon == $_POST[$id][$order]['url']) {
            $selected = 'selected="selected"';
        echo '<option value="'.$socialicon.'" '.$selected.' />'.$socialicon.'</option>';
    }
    

    I am not totally sure about the $_POST array, so you might have to tweak around with that or search for how multidimensional $_POST is accessed.

    If you save the selection somewhere else, e.g. in a database, you can compare it with the value from there.

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

Sidebar

Related Questions

echo <td>Language</td>; echo <td><select id='language' name='language'> <option value=''>Select...</option> <option value='en_US'>English(US)</option> <option value='en_AU'>English(AU)</option> <option value='en_US'>English(UK)</option>
How to set option selected when using jqtransform on select element. I'm using jqtransform
Is it possible to set the selected attribute of an option tag via a
I am trying to set the selected value of a combobox from a style
All i am trying to do is to set the selected value of drop
I am building an MFC C++ application with Use Unicode Character Set selected in
In Flash Builder (flex 4) I try to use next code to set selected
I have a set of selected elements in jQuery: <div class=element></div> <div class=element></div> <div
How do I set the selected item of a listbox? When I use SelectedValue,
I am trying to set the selected values for a MultiSelectList but the page

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.