Welcome Guest, Not a member yet? Register   Sign In
Obtain name and id from Post
#1

[eluser]Juan Velandia[/eluser]
Hello everyone

I have a form like this :
Code:
<input type="text" name="fecha[]" value="" id="a1"/>
<input type="text" name="fecha[]" value="" id="a2"/>
<input type="text" name="fecha[]" value="" id="a3"/>
<input type="text" name="fecha[]" value="" id="a4"/>
<input type="text" name="fecha[]" value="" id="a5"/>
I fill some values in the form, submitted it and the next step is:
Code:
$fecha = $this->input->post('fecha');
print_r($fecha)


And I get something like this

Code:
Array
(
    [0] => 1
    [1] => 24
    [2] => 25
    [3] => 28
    [4] => 38
    [5] => 39
)

I really need to obtain the id besides of the value of each field from the post. How would you do it. Thanks in advance!



#2

[eluser]Juan Velandia[/eluser]
Should I use a Hidden field instead of the ID??
#3

[eluser]solid9[/eluser]
Not tested but try,

Code:
<input type="text" name="fecha[]" value="" id="fecha[]['a1']"/>
<input type="text" name="fecha[]" value="" id="fecha[]['a2']"/>
<input type="text" name="fecha[]" value="" id="fecha[]['a3']"/>
<input type="text" name="fecha[]" value="" id="fecha[]['a4']"/>
<input type="text" name="fecha[]" value="" id="fecha[]['a5']"/>

#4

[eluser]CroNiX[/eluser]
id doesn't send with form data. It's really only good for css/js.

Try
Code:
<input type="text" name="fecha[a1]" value="" id="a1"/>
<input type="text" name="fecha[a2]" value="" id="a2"/>
//etc
etc
#5

[eluser]solid9[/eluser]
@juan
Why do you want to get the id?
What are you trying to do?
#6

[eluser]solid9[/eluser]
Or maybe like this,
Code:
<input type="text" name="fecha[][a1]" value="" id="a1"/>
<input type="text" name="fecha[][a2]" value="" id="a2"/>

Not tested by try.
#7

[eluser]Juan Velandia[/eluser]
@solid9: I am trying to obtain the non checked checkboxes from the form without using hidden values.

Thanks!




Theme © iAndrew 2016 - Forum software by © MyBB