Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

In PHP I have a form that stores and read values in the data structure of an array.

<form method="GET">
    <input type="checkbox" name="field[field_1]" value="1" <?= ($_GET['field']['field_1']==1) ? 'checked' : ''; ?> />
    <input type="checkbox" name="field[field_2]" value="2" <?= ($_GET['field']['field_2']==2) ? 'checked' : ''; ?> />
    <input type="checkbox" name="field[field_3]" value="3"  <?= ($_GET['field']['field_2']==3) ? 'checked' : ''; ?>/>

    <input type="submit" />
</form>

Basically, the code above says that if field_x in the $_GET['field'] array, then mark it as checked. Works beautifully in PHP. The url of the multidimensional array looks like this:

?field%5Bfield_1%5D=0&field%5Bfield_2%5D=1&field%5Bfield_2%5D=1

Now at times from a separate form, the values are trying to be passed by javascript. How can I pass a multidimensional url array from and object so that PHP can read its values from a url?

var object = { field : { field_1 : 1,field_2 : 2, field_3 :3}};

to

/example/url?field%5Bfield_1%5D=0&field%5Bfield_2%5D=1&field%5Bfield_2%5D=1

share|improve this question
    
So in other words you're trying to copy jQuery serialize() ? –  adeneo Mar 8 at 12:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.