vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   How Do I Assign Variables From Dropdown Selection - Form Hack (https://vborg.vbsupport.ru/showthread.php?t=129872)

ctrl-alt-del 10-24-2006 08:12 PM

How Do I Assign Variables From Dropdown Selection - Form Hack
 
I have the Form Hack installed and have a question that I'm hoping someone can answer with relative ease since I'm not getting a response from the developer. My question happens to be basic PHP/HTML, but since I'm not a developer, I can't figure out the issue.

I'm trying to associate values (numeric) based on a selection of a dropdown. The numeric variable is associated to a thread ID wherease the dropdown selection is a recognizable name.

Here's the default code:
Code:

<select name="dropdownanswer1">
<option value="$dropdownchoice1a" <if condition="$dropdownchoice1a == $dropdownanswer1">selected="selected"</if>>$dropdownchoice1a</option>
</select>

I need to change it to something like:
Code:

<option value="$dropdownthreadID" <if condition="$dropdownchoice1a == $dropdownanswer1">selected="selected"</if>>$dropdownchoice1a</option>
Where:
$dropdownthreadID = 100
$dropdownchoice1a = Monday

These variables are called within a newthread_start plugin.
Code:

//EXISTING THREAD ID FOR FORM TO REPLY IN
$formreplythreadid = "$dropdownanswer1";

Here's the problem: I can't seem to figure out how to call the named variable (Monday) when the form is submitted. Instead, I get the numerical value. Perhaps it's just a simple IF statement I need to add that writes Monday into another variable. However, I can't seem to figure it out.

Any help would be appreciated!

Chicago_VLNU_4s 10-27-2006 03:26 AM

woowww.. and what hack is this originally from?

ctrl-alt-del 10-27-2006 12:06 PM

Uhh...read the first sentence.

Chicago_VLNU_4s 10-29-2006 06:41 PM

aww that hack is garbage. I tried it and it made a Generic Form which i couldn't even access

mr clean 10-29-2006 10:26 PM

Quote:

Originally Posted by Chicago_VLNU_4s
aww that hack is garbage. I tried it and it made a Generic Form which i couldn't even access

It worked to perfection for me. I don't think I ran into one single problem other than the thread ID/dropdown issue that ctrl-alt-del is speaking of. Certainly not garbage.

fviper 02-13-2007 06:37 PM

Hey Ctrl Alt Del,

You ever have any luck with this? I got the form to work flawlessly http://www.adversaryguild.com/forums...ad.php?do=form,
but I would really like the thread that the reply goes to be based on the reponse of one of the dropdown selections.

I've tried making a hidden field:
Code:

<input type="hidden" name="threadrepid" value="$dropdownanswer1" />
and comparing the "threadrepid to the various answers we are given, and assigning a threadid from there:
Code:

$formreply = "1";
//$formreplythreadid = $posttid;
if ($threadrepid == $dropdownanswer1b)
    {
    $formreplythreadid = "41";
    }
if ($threadrepid == $dropdownanswer1c)
    {
    $formreplythreadid = "42";
    }
if ($threadrepid == $dropdownanswer1d)
    {
    $formreplythreadid = "45";
    }

But no dice. I would be very interested if you had gotten something like this to work - and how.

I even assigned the vars as suggested - so they could be read into the array properly:
Code:

'threadrepid' => TYPE_STR,
$threadrepid = $vbulletin->GPC['threadrepid'];

Any thoughts? I'm not getting very far with the original thread for this hack ;)

ctrl-alt-del 02-13-2007 07:15 PM

Since I'm not a programmer, I didn't have much success either so I just did it a redundant and manual way. Here's an example:

Code:

$cust["15"] = "Title 1";
$cust["16"] = "Title 2";
$cust["17"] = "Title 3";

$dropdowncust1 = "15";
$dropdowncust2 = "16";
$dropdowncust3 = "17";

Where ="x" is the thread number.

Then in the form,
Code:

<option value="$dropdowncust1" <if condition="$dropdowncust1 == $dropdownanswercust">selected="selected"</if>>$cust[15]</option>
<option value="$dropdowncust2" <if condition="$dropdowncust2 == $dropdownanswercust">selected="selected"</if>>$cust[16]</option>
<option value="$dropdowncust3" <if condition="$dropdowncust3 == $dropdownanswercust">selected="selected"</if>>$cust[17]</option>

It's ugly, I know. :)

fviper 02-13-2007 09:54 PM

Hey,

Thanks for the quick reply. I "think" I figured it out after much cussing lol...

I wound up NOT having to declare any new variables, and NOT having to modify the "form" style. All I did was pretty much what I had been working on previously, but called it slightly differently since the calls I was making were causing SQL to panic because of the array usage.

Here's the code if you're interested:

Code:

//ENABLE FORM TO REPLY TO EXISTING THREAD - 1 = yes, 0 = no
$formreply = "1";
if ($dropdownanswer1 == 'Mage'){
$formreplythreadid = "43";}
if ($dropdownanswer1 == 'Warlock'){
$formreplythreadid = "34";}
if ($dropdownanswer1 == 'Warrior'){
$formreplythreadid = "41";}
if ($dropdownanswer1 == 'Rogue'){
$formreplythreadid = "42";}
if ($dropdownanswer1 == 'Priest'){
$formreplythreadid = "40";}
if ($dropdownanswer1 == 'Hunter'){
$formreplythreadid = "46";}
if ($dropdownanswer1 == 'Paladin'){
$formreplythreadid = "45";}
if ($dropdownanswer1 == 'Shaman'){
$formreplythreadid = "44";}
//EXISTING THREAD ID FOR FORM TO REPLY IN

As you can see, I use this form for recruiting purposes for World of Warcraft *grin*. The single quotes and the literal term of what the variable should be were the key apparently. Thanks for all the help - I hope it finds you well =)


All times are GMT. The time now is 03:37 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.01016 seconds
  • Memory Usage 1,737KB
  • 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
  • (9)bbcode_code_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)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