wordpress and form submition with jquery to php -


i'm trying make options page theme in wordpress file options.php i'm haveing problem submit form , need create submit form function java script , have function creates form , function after save values of form can use in front-page.php

          <?php               function create_form($options) {                     echo "<form id='options_form' method='post' name='form' >\n";                     foreach ($options $value) {                        switch ( $value['type'] ) {                 case "sub-section-3":                     create_suf_header_3($value);                     break;                  case "text";                     create_section_for_text($value);                     break;                  case "textarea":                     create_section_for_textarea($value);                     break;                  case "multi-select":                     create_section_for_multi_select($value);                     break;                  case "radio":                     create_section_for_radio($value);                     break;                  case "color-picker":                     create_section_for_color_picker($value);                     break;             }         }          ?>         <input name="save" type="button" value="save" class="button" onclick="submit_form(this, document.forms['form'])" />         <input name="reset_all" type="button" value="reset default values" class="button" onclick="submit_form(this, document.forms['form'])" />         <input type="hidden" name="formaction" value="default" />          </form>     <?php }  ?>          <script>           function submit_form(element, form)          {           }            </script>               <?php  add_action('admin_menu', 'mynewtheme_add_admin'); function mynewtheme_add_admin() {     global $themename, $shortname, $options, $spawned_options;      if ( $_get['page'] == basename(__file__) ) {         if ( 'save' == $_request['formaction'] ) {             foreach ($options $value) {                 if( isset( $_request[ $value['id'] ] ) ) {                     update_option( $value['id'], $_request[ $value['id'] ]  );                 }                 else {                     delete_option( $value['id'] );                 }             }              foreach ($spawned_options $value) {                 if( isset( $_request[ $value['id'] ] ) ) {                     update_option( $value['id'], $_request[ $value['id'] ]  );                 }                 else {                     delete_option( $value['id'] );                 }             }             header("location: themes.php?page=functions.php&saved=true");             die;         }         else if('reset_all' == $_request['formaction']) {             foreach ($options $value) {                 delete_option( $value['id'] );             }              foreach ($spawned_options $value) {                 delete_option( $value['id'] );             }              header("location: themes.php?page=functions.php&".$_request['formaction']."=true");             die;         }     }     add_theme_page($themename." theme options", "".$themename." theme options",         'edit_themes', basename(__file__), 'mynewtheme_admin'); }  function mynewtheme_admin() {     global $themename, $shortname, $options, $spawned_options, $theme_name;      if ($_request['saved']) {         echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings saved page.</strong></p></div>';     }     if ($_request['reset_all']) {         echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings reset.</strong></p></div>';     }     ?> <div class="wrap">     <h2>settings <?php echo $themename; ?></h2>     <div class="mnt-options"> <?php     create_form($options); ?>     </div><!-- mnt-options --> </div><!-- wrap --> <?php } // end function mynewtheme_admin() ?> 


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -