vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Using <select> dropdown in form - plugin - write to database (https://vborg.vbsupport.ru/showthread.php?t=258121)

wpeloquin 01-31-2011 10:50 PM

Using <select> dropdown in form - plugin - write to database
 
I am having difficulty getting this to work.

In the plugin, i have the following code:

Code:

$rkc_getchar['name'] = htmlspecialchars($rkc_getchar['name']);
$rkc_getchar['class_1'] = htmlspecialchars($rkc_getchar['class_1']);
$rkc_getchar['class_1_level'] = htmlspecialchars($rkc_getchar['class_1_level']);

...

'set_name' => TYPE_STR,
'set_class1' => TYPE_STR,
'set_class1_level' => TYPE_UINT,

now, if i use textbox inputs like the following in my template, then it will update the database, and can be recalled properly (example= misc.php?do=plugin&id=1)
Code:

<input type="text" name="set_name" id="set_name" value="{vb:raw rkc_getchar.name}" class="primary textbox" style="width:75%" />
however, if i try to use a dropdown selection like the following code, the data does not get saved to the database.
Code:

<select name="set_class1_level" id="set_class1_level" value="{vb:raw rkc_getchar.class_1_level}" class="primary" style="width:35%">
        <option value="1">1</option>
        <option value="2">2</option>
        <option value="3">3</option>
        <option value="4">4</option>
        <option value="5">5</option>
</select>

How would i fix this so that a dropdown can be used to limit the choices as needed, instead of having to use an open ended textbox where they could put values outside the proper range?

This seems like it should be an easy fix, and it could just be me staring at code for too long, but i cannot seem to get this to work. Any help would be appreciated.




EDIT: FEB 01, 2011:

OK, it seems that the <select> form IS properly saving to the database, it just does not show up properly when editing. Example, you add an item using the form, and use the name textbox to input "Jimmy", and the <select> to choose number "5", the fields store properly. However, when you go back in to edit that item, it will display "Jimmy" in the text field properly, but the <select> will just show its default value instead of being on "5".

How do I fix that? My workaround at this point is adding
Code:

Current Level: {vb:raw rkc_getchar.class_1_level}
in front of the <select>, and adding
Code:

        <option value="">Choose Level</option>
to the select choices as the default. The problem is that the <select> has to be used every time, even when the user does not wish to update that part of the object, or else the value wipes.

wpeloquin 02-03-2011 06:51 PM

I have solved this. Put the <option> in a loop in the plugin and called it.


All times are GMT. The time now is 07:23 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01015 seconds
  • Memory Usage 1,721KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (5)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (2)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete