<select> tag problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
PatelNehal
Forum Newbie
Posts: 21
Joined: Mon Mar 23, 2009 7:27 am
Location: Gujarat, India

<select> tag problem

Post by PatelNehal »

I am creating a dynamic page where a combobox name is dynamically generated and dynamically name and id property set.

Code: Select all

<select name="select_myname.co.in" id="domain_1">
         <option value="1">1 yr(s)</option>
         <option value="2">2 yr(s)</option>
         <option value="3">3 yr(s)</option>
         <option value="4">4 yr(s)</option>
         <option value="5">5 yr(s)</option>
         <option value="6">6 yr(s)</option>
         <option value="7">7 yr(s)</option>
         <option value="8">8 yr(s)</option>
         <option value="9">9 yr(s)</option>
        <option value="10">10 yr(s)</option>
</select>
 
I am using GET method to redirect this value to the same page and when i tried to read the value in PHP by $_GET['select_myname.co.in'] it returns me null, So is that mean that i cannot use "."(Period) in name of select, but i want to there is no other way for me from that... Plz halp me.
Last edited by Benjamin on Tue Jun 30, 2009 12:08 am, edited 1 time in total.
Reason: Changed code type from text to html.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: <select> tag problem

Post by requinix »

You can use periods but PHP translates them into underscores.

Code: Select all

$_GET["select_myname_co_in"]
wpsd2006
Forum Commoner
Posts: 66
Joined: Wed Jan 07, 2009 12:43 am

Re: <select> tag problem

Post by wpsd2006 »

if you need to parsing it to a group of array later
you can use

Code: Select all

 
name="select_myname['co']['in']" 
 
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: <select> tag problem

Post by requinix »

In case you weren't generating the name as "select_" + a domain name like I thought, and do want arrays, technically you should be using

Code: Select all

name="select_myname[co][in]"
User avatar
PatelNehal
Forum Newbie
Posts: 21
Joined: Mon Mar 23, 2009 7:27 am
Location: Gujarat, India

Re: <select> tag problem

Post by PatelNehal »

Hello Mr. tasairis Thank you very much for solving my problem, no book or any article never told this characteristic of PHP. Thank you very much all of you for your help. :offtopic:
wpsd2006
Forum Commoner
Posts: 66
Joined: Wed Jan 07, 2009 12:43 am

Re: <select> tag problem

Post by wpsd2006 »

name="select_myname['co']['in']"
lol this one should be without the ' , i forget this is html
Post Reply