jQuery Clone问题查找元素

时间:2013-11-26 20:26:44

标签: jquery ajax asp-classic

I am using the code below for cloning the form to add new records. My question is i cant get asp to read the new values it only reads the first set not the clone values. I thought of using ajax but im not sure how to code it.  

    $(function () {
     $('#btnAdd').click(function () {
        var num     = $('.clonedInput').length, // how many "duplicatable" input fields we currently have
            newNum  = new Number(num + 1),      // the numeric ID of the new input field being added
            newElem = $('#entry' + num).clone().attr('id', 'entry' + newNum).fadeIn('slow'); // create the new element via clone(), and manipulate it's ID using newNum value
    // manipulate the name/id values of the input inside the new element
        // H2 - section
        newElem.find('.heading-reference').attr('id', 'ID' + newNum + '_reference').attr('name', 'ID' + newNum + '_reference').html('Contact #' + newNum);

        // Title - select
        newElem.find('.label_ttl').attr('for', 'ID' + newNum + '_title');
        newElem.find('.select_ttl').attr('id', 'ID' + newNum + '_title').attr('name', 'ID' + newNum + '_title').val('');

        // First name - text
        newElem.find('.label_fn').attr('for', 'ID' + newNum + '_first_name');
        newElem.find`enter code here`('.input_fn').attr('id', 'ID' + newNum + '_first_name').attr('name', 'ID' + newNum + '_first_name').val('');

        // Last name - text
        newElem.find('.label_ln').attr('for', 'ID' + newNum + '_last_name');
        newElem.find('.input_ln').attr('id', 'ID' + newNum + '_last_name').attr('name', 'ID' + newNum + '_last_name').val('');

        // Color - checkbox
        newElem.find('.label_checkboxitem').attr('for', 'ID' + newNum + '_checkboxitem');
        newElem.find('.input_checkboxitem').attr('id', 'ID' + newNum + '_checkboxitem').attr('name', 'ID' + newNum + '_checkboxitem').val([]);

        // Skate - radio
        newElem.find('.label_radio').attr('for', 'ID' + newNum + '_radioitem');
        newElem.find('.input_radio').attr('id', 'ID' + newNum + '_radioitem').attr('name', 'ID' + newNum + '_radioitem').val([]);

        // Email - text
        newElem.find('.label_email').attr('for', 'ID' + newNum + '_email_address');
        newElem.find('.input_email').attr('id', 'ID' + newNum + '_email_address').attr('name', 'ID' + newNum + '_email_address').val('');

    // insert the new element after the last "duplicatable" input field
        $('#entry' + num).after(newElem);
        $('#ID' + newNum + '_title').focus();

    // enable the "remove" button
        $('#btnDel').attr('disabled', false);

    // right now you can only add 5 sections. change '5' below to the max number of times the form can be duplicated
        if (newNum == 5)
        $('#btnAdd').attr('disabled', true).prop('value', "You've reached the limit");
    });

    $('#btnDel').click(function () {
    // confirmation
        if (confirm("Are you sure you wish to remove this section? This cannot be undone."))
            {
                var num = $('.clonedInput').length;
                // how many "duplicatable" input fields we currently have
                $('#entry' + num).slideUp('slow', function () {$(this).remove(); 
                // if only one element remains, disable the "remove" button
                    if (num -1 === 1)
                $('#btnDel').attr('disabled', true);
                // enable the "add" button
                $('#btnAdd').attr('disabled', false).prop('value', "add section");});
            }
        return false;
             // remove the last element

    // enable the "add" button
        $('#btnAdd').attr('disabled', false);
    });

    $('#btnDel').attr('disabled', true);

ASP CODE SAMPLE尝试抓取克隆字段。我意识到这些名字在asp中是不同的,但它是我正在使用的。它在提交期间无法读取字段     <%     如果Session(“Login”)=“”那么                     Response.Redirect“../Login.asp”     结束如果

Call LogPage("View")

if request.QueryString("Action") = "S" then
                'Read Form fields from posting of page into session variables

                'Continue to read all of the form fields here
                session("ContactCounter")=request.Form("ContactCounter")
                response.write request.Form("SigneeFirst2") & "<br>"
                i = 2
    for x = 1 to Request.Form.count() 
         Response.Write(Request.Form.key(x) & " = ") 
         Response.Write(Request.Form.item(x) & "<br>") 
     next 
 '              do while i <= session("ContactCounter")
                                response.write request.Form("SigneeFirst2_" & session("ContactCounter")) & "<br>"
'                               i = i + 1
'               loop

                session("C_SigneeSalutation")= request.form("C_SigneeSalutation")
                session("C_SigneeFirst")= request.form("C_SigneeFirst")
                session("C_SigneeLast")= request.form("C_SigneeLast")
'response.Redirect("sAdd.asp")

end if
response.write ">>" & request.form("ID2_C_SigneeSalutation")
%>

0 个答案:

没有答案