Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8176367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:08:44+00:00 2026-06-06T23:08:44+00:00

i have a form to which the form elements are appended using the onclick

  • 0

i have a form to which the form elements are appended using the onclick event.

the form elements along with their values and label are then maintained in an array .

function save_form() {
    var x = document.getElementById("formBuilder");
    var elements_data = new Array;
    for (var i = 0; i < x.length; i++) {
        if (x.elements[i].type == 'checkbox' || x.elements[i].type == 'radio') {
            var all_ele_value = [];
            var ele_id = x.elements[i].id;
            $("input:" + x.elements[i].type + "[name=" + ele_id + "[]]").each(function () {
                all_ele_value.push($(this).val());
            });
            var end_value = all_ele_value.join(";");
        }
        else if (x.elements[i].type == 'select-one') {
            var ele_id = x.elements[i].id;
            var end_value = $("#" + ele_id + " option").map(function (i, n) {
                return n.value;
            }).get().join(";");
        }
        else {
            var end_value = x.elements[i].value;
        }
    }
    var form_data = JSON.stringify(elements_data);
    $.post(software_url + 'form_manager/save_form', {
        'form_data': form_data
    }, function (data) {
        alert(data);
    });
}

now i want to encode form_data in my php file . I want to know a way to do that because json_decode does not work. Iam getting all the output in json format .BUt i want to iterate through it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T23:08:47+00:00Added an answer on June 6, 2026 at 11:08 pm

    I’m strongly going to recommend two things to you.

    One is learning about jQuery.serialize, which does the heavy lifting work you did to put all the elements together in a string.

    Moving right along, json_decode does work, unless the JSON string is invalid, check what you are receiving and test it your JSON syntax on JSONLint – to see if it’s correct.

    In php, you have to use json_decode, and then you can go through it.

    <?php
    $array = json_decode($json_string);
    foreach ($array as $key => $value) {
         echo "key: ". $key ." => ". $value;
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my application I have a form, which elements are named using a certain
I have a form(HTML) in which I want to navigate through the elements using
I have a form which contains a lot of elements, my DB guy has
I have web form with a panel which has form elements in side it.
I have a base and derived class called Node which form elements of a
I have a simple MVC form with the following elements: <%= Html.TextBox(FechaInicio) %> Which
I have a block of form elements which I would like to clone and
I have a form which can populate from 1-100 elements based on a user's
I have a search form regarding property search having some elements on which search
I have the following problem. I’ve made a form which change the form elements

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.