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

  • Home
  • SEARCH
  • 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 4118840
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T23:00:47+00:00 2026-05-20T23:00:47+00:00

I am currently creating a backend. What I need is some jquery to insert

  • 0

I am currently creating a backend. What I need is some jquery to insert some different form fields. I can for example have this code:

<div>
    <div>
        Name
    </div>
    <div>
        Type
    </div>
    <div>
        <a class="edit" href="#">Edit</a>
    </div>
</div>

This code needs to get converted so the Name and Type text is insted the values of two input fields when I click a.edit

EDIT:

I’ve tried this code – but when I click “a.ff-save” it does not alert??? What is my problem?

<script type="text/javascript">
$(document).ready( function() {
    var this_form_id = $("input#form_id").val();
    $("#formfield-list div.formfield-ff:odd").css('background', '#f6f6f6');


    $("a.ff_add").click( function() {
        var name_val = $("input#new_field_name").val();
        var type_val = $("input#new_field_type").val();
        var demand_val = $("input#new_field_demand").val();
        $.ajax({
            type: "POST",
            url: "{pref_folder}/admix/forms/addFormField",
            data: ({ form_id: this_form_id, field_name: name_val, field_type: type_val, field_demand: demand_val }),
            success: function(text) {

                $.ajax({
                    type: "post",
                    url: "{pref_folder}/admix/forms/getFormFields",
                    data: { form_id: this_form_id },
                    success: function(t) {
                        $("#formfield-list").empty().append(t);
                        $("#formfield-list div.formfield-ff:odd").css('background', '#f6f6f6');
                    },
                    dataType: "html"
                });


                $(".add-succes-message").empty().append('<div class="msg">'+text+'</div>');
                $(".add-field-row").slideUp(500, function(){
                    $(".add-field-row").slideDown(500);
                }).delay(3500);
                $(".add-succes-message").slideDown(500, function(){
                    $(".add-succes-message").slideUp(500);
                }).delay(3500);

            },
            cache: false,
            async: false,
            dataType: "html"
        });
    });

    $("a.ff-save").click(function (){
        alert("ok");
    });

    $("a.ff-edit").click(function (){
        var fid = $(this).prev().val();

        var nameValue = $("#ff-"+fid+" div.ff-name").html().trim();
        var typeValue = $("#ff-"+fid+" div.ff-type").html().trim();
        var demandValue = $("#ff-"+fid+" div.ff-demand").html().trim();
        var typeInt;

        if( typeValue == "Tekstfelt, 1 linje" )
        {
            typeInt = 1;
        } else {
            typeInt = 0;
        }


        $("#ff-"+fid+" div.ff-name").html('<input type="text" name="name" class="jq-input" value="'+nameValue+'" />');
        $("#ff-"+fid+" div.ff-type").html('<input type="text" name="type" class="jq-input" value="'+typeInt+'" />');
        if( demandValue == "Ja")
        {
            $("#ff-"+fid+" div.ff-demand").html('<input type="checkbox" name="demand" class="jq-input" value="" checked="checked" />');
        } else {
            $("#ff-"+fid+" div.ff-demand").html('<input type="checkbox" name="demand" class="jq-input" value="" />');
        }

        $("#ff-"+fid+" .ff-edit, #ff-"+fid+".ff-delete").hide();
        $("#ff-"+fid+" div:last").html('<a href="#" class="ff-save">Save</a>');
    });

    $("a.ff-delete").click();
});
</script>
  • 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-20T23:00:47+00:00Added an answer on May 20, 2026 at 11:00 pm

    Check this jQuery plugin. It exactly does what you are looking for.

    JEditable

    If you are not inclined towards using the plugin, then try the code below:

    <div>
        <div>
            <label class="editable">Name</label>
            <input class="editable" type="text" name="name" style="display:none"/>
        </div>
        <div>
            <label class="editable">Type</label>
            <input class="editable" type="text" name="type" style="display:none"/>
        </div>
        <div>
            <a class="edit" href="#">Edit</a>
        </div>
    </div> 
    <script type="text/javascript">
        $(function(){
            $(".edit").click(function(){
                var $this = $(this);
                var text = $this.text();
                if(text=="Edit"){
                    $this.text("Cancel");
                }
                            else{
                                 $this.text("Edit");
                            }
                $(".editable").toggle();
            });
    
            $("input.editable").change(function(){
                $(this).prev().text($(this).text());
    
            });
        });
    </script>
    

    EDIT:

    To bind the click event handler to the anchor element use the live function of jQuery.
    e.g:

    $("a.ff-save").live("click", function (){         
     alert("ok");     
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently creating a form validation script based on the jQuery validator plugin .
I am currently creating a website in php that has a database backend (can
im currently creating a graph for an app, using coreplot and have a problem
I'm currently creating a neighbourhood graph by doing roughly this: for every voxel look
We are currently creating an InfoPath 2007 form is deployed in SharePoint 2007. In
At the moment, I am creating some kind of admin panel/backend for my site.
I'm currently creating my first custom theme for Tumblr and I can't find any
I have a backend system that currently returns a domain object. I want to
I am currently creating a mobile application. I am using cakephp2.0 as my backend
I am currently creating an application for compiling multiple java projects in one go

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.