Page 1 of 1

<select> tag problem

Posted: Sun Jun 28, 2009 6:28 pm
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.

Re: <select> tag problem

Posted: Sun Jun 28, 2009 7:36 pm
by requinix
You can use periods but PHP translates them into underscores.

Code: Select all

$_GET["select_myname_co_in"]

Re: <select> tag problem

Posted: Sun Jun 28, 2009 9:26 pm
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']" 
 

Re: <select> tag problem

Posted: Sun Jun 28, 2009 10:28 pm
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]"

Re: <select> tag problem

Posted: Mon Jun 29, 2009 7:53 am
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:

Re: <select> tag problem

Posted: Mon Jun 29, 2009 10:37 pm
by wpsd2006
name="select_myname['co']['in']"
lol this one should be without the ' , i forget this is html