0
  1. Newbie here with jquery
  2. I would like to add a couple of input fields to a form I have already created
  3. Reason is - in case a new user wants to add new degree to the one already in the database
  4. This is my jquery code

    $("#addinst").click(function(){ $("mainform").append("<p> <label align="left">Institution #1:</label> <input name="EdInstitutionName1" type="text" value="" size="70" maxlength="100" /> </p>");

  5. This is part of the form the form

    <form id="someform" > <fieldset id="mainField"> <p><label align="left">Institution #1:</label> input name="EdInstitutionName1" type="text" value="" size="70" maxlength="100" /> tr> td align="left">City, State #1:</td> td><input name="EdInstitutionLocation1" type="text" value="" size="70" maxlength="100" /></td> </tr>

1 Answer 1

1

It seems that inside of your jQuery code, you are missing the id of the form. To select your form, use:

$('#mainform').append

instead of

$('mainform').append

In jQuery, ids need to have a # in front of them. Without a # symbol, jQuery looks for tags with that name. Similarly, classes are selected using . in front of the class name.

For more information about jQuery selectors, you can refer to the jQuery selector API

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks Kyle, here is my fiddle link for clarity. jsfiddle.net/koba/58tmm/2 The idea is to create 5 new input fields to add another institution, I have it trying to insert a field first for test, but nothing appears to be working
@koba In your fiddle, you don't have anything with an id of mainform. I updated your fiddle: jsfiddle.net/58tmm/6

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.