Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 01-31-2011, 10:50 PM
wpeloquin wpeloquin is offline
 
Join Date: May 2006
Location: Behind you...
Posts: 143
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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.
Reply With Quote
  #2  
Old 02-03-2011, 06:51 PM
wpeloquin wpeloquin is offline
 
Join Date: May 2006
Location: Behind you...
Posts: 143
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:35 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.04366 seconds
  • Memory Usage 2,170KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (5)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (2)post_thanks_box
  • (2)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (2)post_thanks_postbit_info
  • (2)postbit
  • (2)postbit_onlinestatus
  • (2)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete