开发者

jQuery passing values from one form to preivous form

开发者 https://www.devze.com 2022-12-21 04:08 出处:网络
Is it possible to find out what form you\'re currently on from a js file? This is my issue.. I have a form, form1, that includes a table.. when a row in the table is clicked on another form pops up,

Is it possible to find out what form you're currently on from a js file?

This is my issue.. I have a form, form1, that includes a table.. when a row in the table is clicked on another form pops up, form2. If the user "saves successfully" on form2, the form clos开发者_开发知识库es and form1 comes back into focus..my question, is it possible to send an id or call a function when that form closes to set/change values

what I want to do is change the row attribute of the row the user saved on form1. example:

table.row[1].color = red 

after save

table.row[1].color = green

how do i access/set values of the table on form1.. I would assume I need to do something like this once I know what form I'm on..this is all being done in a js file..

foreach(row in table)
    {
        if (FormName.GeneralReport.rows[i]).attr("userid") == 'id') 
        {
            $(FormName.GeneralReport.rows[i]).attr("isValid", "True");
            $(formNameGeneralReport.rows[i]).css("background-color:", "green");
        }
    }

or... can I add a function to form1 and call that function from my js file?


It's hard to give an detailed answer because the whole construct is described a bit vague. Assuming that this all happens entirely at the client side and thus no new HTTP requests are been sent to the server side, generally you can just "pass" values through by setting some (invisible) DOM element and/or attribute with that value. Add for example an <input type="hidden" name="formid"> to the form in the dialog and add something like this to the edit button:

$('.edit').click(function() {
    var formid = $(this).parents('form').attr('id');
    $('#dialog input[name=formid]').val(formid);
    // ...
    $('#dialog').show();    
});

..and add something like this to the save button of the dialog:

$('#dialog .save').click(function() {
    var formid = $(this).parents('#dialog').find('input[name=formid]').val();
    var form = $('#' + formId);
    // ...
});
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号