Jump to content

[SOLVED] Get form element type?


frost

Recommended Posts

The names and values of the form fields are all that php receives and when check boxes and radio buttons are not selected/checked, the variable with their name is not even set.

 

Since the form code is yours, you know the names and can write php code that matches.

 

If you are creating dynamically generated form fields, you would need to use field names that indicate what type they were. If you have more than one field of a type, using an array makes it easier to iterate over all the values in php code using a foreach() loop.

 

If this does not answer your question, you would need to provide a specific example of what you are trying to do.

As the previous poster mentioned, PHP doesn't get the type of the input, only the name and the value. If you want to have the type, you will need to provide it to PHP via various methods. One way is to let PHP know with a hidden input text field that tells PHP the type of the field. Another way is to append or prepend the field type to the name, then extract it when you receive it.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.