select multiple

Discussion forum for MOD Writers regarding MOD Development.
Locked
wutwut
Registered User
Posts: 13
Joined: Tue Apr 27, 2010 12:01 am

select multiple

Post by wutwut »

how do I get a multiple select into php array

I tried using

Code: Select all

<select name="cats[ ]" MULTIPLE SIZE='{CATS_SIZE}' width="95%">
<!-- BEGIN cats -->
<option value="{cats.ID}" {cats.SELECTED}>{cats.NAME}</option>
<!-- END cats -->
</SELECT>

Code: Select all

$s_cats[] = request_var('cats', 'FALSE');
but it either gives only the last id or FALSE
plz help
BondGamer
Registered User
Posts: 436
Joined: Mon Dec 15, 2003 7:49 pm
Contact:

Re: select multiple

Post by BondGamer »

Your name for the select field does not match what you are asking for in request_var. Select name is "cats[ ]" and request_var is "cats". They have to match.
My phpBB3 Mods: - None active =[
ToonArmy
Former Team Member
Posts: 4608
Joined: Sat Mar 06, 2004 5:29 pm
Location: Worcestershire, UK
Name: Chris Smith
Contact:

Re: select multiple

Post by ToonArmy »

BondGamer wrote:Your name for the select field does not match what you are asking for in request_var. Select name is "cats[ ]" and request_var is "cats". They have to match.
Incorrect [] creates an array of results the variable is still just cats but it's an array.

Code: Select all

$cats = request_var('cats', array(0)); 
Chris SmithGitHub
Locked

Return to “[3.0.x] MOD Writers Discussion”