tags:

views:

22

answers:

1

I have a widget inside of my asp.net page from a third party. I can not use nested forms, so I am changing the method and action of the asp.net temporarily to work with the widget.

I have a js method the the elements in my widget method call

function changeActionAndMethodOnFormAndSubmit(newAction, newMethod, newName) {
    var theForm = document.forms['aspnetForm'];
    if (!theForm) {
        theForm = document.Form1;
    }
    theForm.action = newAction;
    theForm.method = newMethod;
    theForm.name = newName;
    theForm.submit();
}

I would like to remove all input elements on the page before I submit the form except the onces I need. I know the exact ID of the elements based on the paramter newName, but for now, lets say im trying to remove all input elements that don't have an input.id of x or y.

+2  A: 

This should do:

$('input:not(#x,#y)', theform).remove()
Greg