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 6329369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:39:00+00:00 2026-05-24T17:39:00+00:00

I have the following view in codeigniter- say edit_res_view- <html> <table> <? foreach ($list

  • 0

I have the following view in codeigniter- say edit_res_view-

<html>
<table>
    <? foreach ($list as $key => $value): ?>
        <tr><td><?= $key ?> :</td><td><input type="text" name='<?= $key ?>' size="25" value='<?php echo $value; ?>'/></td></tr>
    <? endforeach; ?>

    <tr><td colspan="2"><center><input type="submit" id="submit" size="40" value="SAVE" />

</table>

Now I have another jquery function in another view which takes the values from the name attributes of this form to send as POST data to another function –

$("#submit").live("click",function(){

    $.ajax({
        url: "http://localhost/codeigniter_local/index.php/manage_resources/doupdate_des",
        type:"POST",                                         
        data:"d_id="+$("[name='d_id']").val()+
              "&cpu_brand="+$("[name='cpu_brand']").val()+
              "&processor="+$("[name='processor']").val()+
              "&ram="+$("[name='ram']").val()+
              "&hdd="+$("[name='hdd']").val()+
              "&mac_id_wired="+$("[name='mac_id_wired']").val()+
              "&mac_id_wireless="+$("[name='mac_id_wireless']").val()+
              "&os="+$("[name='os']").val()+
              "&os_license_no="+$("[name='os_license_no']").val()+
              "&monitor_sno="+$("[name='monitor_sno']").val()+
              "&keyboard_sno="+$("[name='keyboard_sno']").val()+
              "&mouse_sno="+$("[name='mouse_sno']").val()+
              "&sno="+$("[name='sno']").val()+
              "&date_of_purchase="+$("[name='date_of_purchase']").val()+
              "&warranty="+$("[name='warranty']").val()+
              "&comments="+$("[name='comments']").val(),

        success:function(html){

            oTable.fnReloadAjax('http://localhost/codeigniter_local/index.php/manage_resources/json/1');
            alert("Done !");
            $("#form1").dialog("close");
        },  
        ERROR: function(html){                                             
            alert(html);                                        
        }  
    });
} );//for submit

Now the problem is that I want to loop through the values for the “data:” attribute of the jquery function instead of hardcoding it, as I have done above.

How to go about it? (btw the $list array is passed as an argument to edit_res_view through my controller).

  • 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-05-24T17:39:01+00:00Added an answer on May 24, 2026 at 5:39 pm

    Something like this should work using the jQuery map function:

    var postData = $("#form1 input:text").map ( function (J, node) {
        var jThis   = $(node);
        return jThis.attr ('name')  + '=' +  jThis.val ();
    } ).get ().join ('&');
    
    
    $.ajax({
        url:  "http://localhost/codeigniter_local/index.php/manage_resources/doupdate_des",
        type: "POST",                                         
        data: encodeURI (postData)
        ... ...
    

    That code assumes that the form has an id of “form1”, and helps ensure that only the correct forms inputs are used.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have the following loop in my view foreach ($value as $row): echo
I have the following files: view.jsp <@ page import=... <bean:define id=mForm name=myForm type=MyForm/> <html:form
I have following table structure: Table: Plant PlantID: Primary Key PlantName: String Table: Party
I have following code in my MVC2 view: <tr class=edit style=display:none> <td> <%= Html.DropDownList(drpFields,
I have following code in my MVC2 view: <tr class=edit style=display:none> <td> <%= Html.DropDownList(drpFields,
I Have following code: Controller: public ActionResult Step1() { return View(); } [AcceptVerbs(HttpVerbs.Post)] public
I have following situation: I have loged user, standard authentication with DB table $authAdapter
I have following foreach-loop: using System.IO; //... if (Directory.Exists(path)) { foreach(string strFile in Directory.GetFiles(path,
I have following situation. A main table and many other tables linked together with
I have following text in a file 23456789 When I tried to replace the

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.