WordPress.org

Ready to get started?Download WordPress

Forums

not displaying selected item (2 posts)

  1. accounts@push
    Member
    Posted 2 years ago #

    my settings API <select> element is storing the selection in the database however when i submit the form it reloads the options and does not display the selected option - for example my options go from 1 to 12.
    when i select option 12 and click submit the page reloads and option 1 is displayed in the drop down list. option 12 is saved in my database and i can use it in my theme but for users who want to change which value they have and cant remember which ones they picked last this is incredibly inconvenient!

    here is the function im using to display and store the options in my database:

    function  setting_dropdown_fn() {
    	$options = get_option('rtms_options');
    	echo "<select name='rtms_options[page_string]'>" ;
       $pages = get_pages();
      foreach ( $pages as $pagg ) {
      	$option = '<option value="' . get_page_link( $pagg->ID ) . '">';
    	$option .= $pagg->post_title;
    	$option .= '</option>';
    	echo $option;
      }
    echo '</select>';}
  2. accounts@push
    Member
    Posted 2 years ago #

    for those who find this hard to read im essentially trying to get the <select> element to display the currently selected option when the page loads

Topic Closed

This topic has been closed to new replies.

About this Topic