Jump to content

Input type=checkbox empty value ?!


[dx]

Recommended Posts

Hi,

 

I'm trying make some form for user registration, and I have multiple checkboxes for categories.

 

So I'm using:

<input type="checkbox" name="category[]" value="category_1"> Category 1<input type="checkbox" name="category[]" value="category_2"> Category 2<input type="checkbox" name="category[]" value="category_3"> Category 3<input type="checkbox" name="category[]" value="category_4"> Category 4etc..

It's all in <form> tag.

 

When I go to console, I can see only value attribute like:

<input type="checkbox" name="category[]" value> Category 1

But if I go to view source, there's html as it should be. What can cause it?

 

This is reason why I can't fetch data correctly with .serializeArray().

 

How to solve it?

Link to comment
Share on other sites

There might be some missing quote or something similar in your code. Re-check the code.

<input type="checkbox" name="category[]" value="category_1"> Category 1<input type="checkbox" name="category[]" value="category_2"> Category 2<input type="checkbox" name="category[]" value="category_3"> Category 3<input type="checkbox" name="category[]" value="category_4"> Category 4

^Works fine

Link to comment
Share on other sites

Hi dsonesuk,

 

Thank your for reply.

 

I tryed both, php generating and static html like value="something".

I'm sure, checked twice, that it's double quotes correctly, and it's utf8.

Link to comment
Share on other sites

Are you expecting to access an array category[], because category[] is just your checkbox name.

 

What are you applying .serializeArray() to?

Edited by johncc
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...