javascript - Input Checkbox Array, if unchecked no value is sent by jQuery -


I have a form that is dynamically created, so I have an input array!

Resolve: & lt; Input type = "hidden" name = "smoker_patient [id]" value = "off" /> Hidden fields for each checkbox with the same ID! #

Like:

  & lt; Tr & gt; & Lt; Td> [Luggage] & lt; Input type = "checkbox" name = "smoker_parit [1]" class = "smoker" id = "cbx1" check = "check" /> [Luggage] & lt; / Td> & Lt; / Tr & gt; & Lt; TR & gt; & Lt; TD & gt; [Luggage] & lt; Input type = "checkbox" name = "smoker_ family [2]" class = "smoker" id = "cbx2" /> [Luggage] & lt; / Td> & Lt; / Tr & gt; & Lt; TR & gt; & Lt; TD & gt; [Luggage] & lt; Input type = "checkbox" name = "smoker_parit [3]" class = "smoker" id = "cbx3" check = "check" /> [Luggage] & lt; / Td> & Lt; / Tr & gt;   

As you can see, cbx1 and cbx3 are checked. (To show only the error), but only in the array sent by jQuery, only

  Smoker_patient at [0] = 'smoker_patient [1] =' at ' < / Pre> 

but it should be ...

  smoker_patient [0] = 'smoker_patient at [1] =' off 'smoker_patient [2] =' at '  

So I get an error in PHP:

Notice: Undefined Offset: New in Exposure. In WPP2 < p>

I am unsure about your syntax, your input Naming Sections You are finding out what your doing well, I do not think you are unaware that if you have name = "" all your $ _ POST or $ _ GET of that input will only appear more than one I'm sure you thought about it and name = "smoker_patient []" must be just a pseudo-position holder.

It is being said, if the problem is not the code then you can contact it like this.

You need to use PHP to make sure that the $ _POST value is set somewhere. When a checkbox is selected or checked and the form is sent for example through $ _POST, the information is not sent like the other HTML objects. Instead, it is sent to the PHP page dealing with your $ _POST response as on or off .

@ SmithWeatherSite is the only way to do this to ensure that it is set or checked, this is a isset ($ _ POST ['checkbox']) to use. .

If your classes are dynamic then you can use php and a simple counter to make sure all the dynamic checkboxes are given such unique names and identifiers ... < P> First of all see how many boxes I want and then ... $ totalNumOfBoxes = 3; For ($ i = 0; $ i & lt; $ coolmanoff box = $ i ++) {echo '

Then you will have a series of boxes with a unique identifier, so that when you submit the form, do not confuse each checkbox in the $ _ POST with its brother checkbox array

On the other hand, in the PHP file dealing with the $ _ POST response, you can call yourself a $ _ GET Will fill the variable to fill it with the isset () and the checkbox is not possible to see that There are many boxes, by testing the boundaries ...

I will create a form that has a method: post and action in all these boxes: myHandlerPHPFile.php ? Boxcount = 3 So when you go to this side of the POST request you can create your $ totalNumOfBoxes = $ _GET ['boxCount'] .

You can set the action: myHandlerPHPFile.php? Count the boxcount = 3 using the same look which also adds this math variable to the mix.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -