views:

37

answers:

2
(function($) {
  var selectIds = new Array();
  var sortOnSelect = false;
  var nameModifier = "tsms";
  function removeFormField() {
    $(id).remove();
  }

All the other functions after this work. This function says it undefined using firebug.

removeFormField is not defined

Another function creates this field and the top function is suppose to remove it.

<label for="txt4">Field 4&nbsp;&nbsp;<input type="text" id="txt4" name="txt[]" size="20">&nbsp;&nbsp;<a onclick="removeFormField(&quot;#row4&quot;); return false;" href="#">Remove</a></label>
+3  A: 

You need to put your function outside of the document ready function then call it from within.

(function($) {
   var selectIds = new Array();
   var sortOnSelect = false;
   var nameModifier = "tsms";
   removeFormField();
});

function removeFormField() {
   $(id).remove();
}
Zacho
Is this intended to be a plugin or a startup function?
Zacho
A: 

In addition to the problem where the function is declared in the jQuery ready() handler, your function as written does not take an input value.

It should be:

function removeFormField(id) {
    $(id).remove();
}
R. Bemrose