If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > JAVA > dynamically add form fields jquery

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old
Registered User
 
Join Date: Nov 2011
Posts: 16
dynamically add form fields jquery

after an autocomplete ui call, I retrieve a json_encoded array, which looks like the following:

Code:
{"0":{"id":"","value":"CAA11 - Mountain View, CA","facname":"Main Shop","address":"1234 My Road","city":"Mountain View","state":"California","zip":"99999"},"Long_Name":["OPPS1","200TH EXAMPLE CO","UNIT55","UNIT88","809 DEPL","ANOTHER EX","US8888 EXAMPLE","YETANOTHER"]}
I'm interested in the key: "Long_Name". I need to a) dynamically add the appropriate number of html text input boxes to hold the "Long_Name" values. In the above example, 8 html input fields would be added, then populated with the Long_Name data.

any ideas, with jquery?

I have the other keys, (address, city, state for example) auto-populating already existing html fields. I'm just struggling with dynamically adding the fields, then filling them with the Long_Name data.

here's what I have so far:

Code:
$(function() {

        $('#facname').val("");
        $('#address').val("");
        $('#city').val("");
        $('#state').val("");
        $('#zip').val("");

        //autopops fields if user fills out facid field
        $("#facid").autocomplete({
            source: "facils.php",
            minLength: 2,
            select: function(event, ui) {
                //all of the below htlm fields auto-complete fine...
                $('#faccity').val(ui.item.id);
                $('#facid_id').val(ui.item.id);
                $('#facname').val(ui.item.facname);
                $('#address').val(ui.item.address);
                $('#city').val(ui.item.city);
                $('#state').val(ui.item.state);
                $('#zip').val(ui.item.zip);
               //??dont know how to add the Long_Name data??
            }
        });
    });
thanks!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On