Tammu
asked on
Getting uncaught type error $ not defined and also Javascript function not defined
I have a form with an anchor tag called add another staff member, if you see the link below and go all the way down you will the anchor tag. When I click on it, its supposed add a block of elements so the a user can enter another staff details.
http://novice-here.coffeecup.com/forms/Membership-Application/
here is the code I am trying to use and it won't work. Getting uncaught type error $ not defined and also addStaffMember function not defined
and the script is
What am I doing wrong. Thanks and appreciate it
http://novice-here.coffeecup.com/forms/Membership-Application/
here is the code I am trying to use and it won't work. Getting uncaught type error $ not defined and also addStaffMember function not defined
<div id="staffMember_staffMemberNumber" style="display:none">
<div class="fb-item fb-100-item-column" class="staffMember_staffMemberNumber" style="opacity: 1;">
<div class="fb-html">
<div class="staff-member-staffMemberNumber">
<h3>
Staff Member 4
</h3>
</div>
</div>
</div>
<div class="fb-item fb-50-item-column" class="staffMember_staffMemberNumber" style="opacity: 1;">
<div class="fb-grouplabel">
<label class="staff-member-staffMemberNumber" style="display: inline;">Full Name</label>
</div>
<div class="fb-input-box">
<input name="staff-member-name-staffMemberNumber" class="staffMember_staffMemberNumber" type="text" maxlength="254" value="staff-member-name-value" autocomplete="off"></input>
</div>
</div>
<div class="fb-item fb-50-item-column" class="staffMember_staffMemberNumber" style="opacity: 1;">
<div class="fb-grouplabel">
<label class="staff-member-staffMemberNumber" style="display: inline;">Title</label>
</div>
<div class="fb-input-box">
<input name="staff-member-title-staffMemberNumber" class="staffMember_staffMemberNumber" type="text" maxlength="254" value="staff-member-title-value" autocomplete="off"></input>
</div>
</div>
<div class="fb-item fb-50-item-column" class="staffMember_staffMemberNumber" style="opacity: 1;">
<div class="fb-grouplabel">
<label class="staff-member-staffMemberNumber" style="display: inline;">Email Address</label>
</div>
<div class="fb-input-box">
<input name="staff-member-email-staffMemberNumber" class="staffMember_staffMemberNumber" type="email" maxlength="254" value="staff-member-email-value" autocomplete="off"></input>
</div>
</div>
<div class="fb-item fb-50-item-column" class="staffMember_staffMemberNumber" style="opacity: 1;">
<div class="fb-grouplabel">
<label class="staff-member-staffMemberNumber" style="display: inline;">Professional Role Within Firm</label>
</div>
<div class="fb-input-box">
<input name="staff-member-role-staffMemberNumber" class="staffMember_staffMemberNumber" required type="text" maxlength="254" value="staff-member-role-value" autocomplete="off"></input>
</div>
</div>
<div class="fb-item fb-100-item-column" style="height: 20px; min-height: 5px; opacity: 1;">
<div class="fb-spacer">
<div class="staffMember_staffMemberNumber">
</div>
</div>
</div>
</div> <input type="hidden" value="4" name="staffMemberCount" id="staffMemberCount"> <a id="add-another" onclick="addStaffMember();" href="javascript:;"><strong>+ Add Another Staff Member</strong></a>
and the script is
<script>$(document).ready(function(){
function addStaffMember() {
// Increment the number of staff member sub-forms.
var newStaffMemberNumber = parseInt($('#staffMemberCount').val()) + 1;
// Update the counter in the form.
$('#staffMemberCount').val('' + newStaffMemberNumber);
// Clone the staffMember div.
$staffMemberTemplate = $('#staffMember_staffMemberNumber');
$cloned = $staffMemberTemplate.clone(true);
// Fix the html for the next staff member count number.
$cloned.html($cloned.html().replace('staffMemberNumber',newStaffMemberNumber,'g'));
$cloned.html($cloned.html().replace('staff-member-name-value',''));
$cloned.html($cloned.html().replace('staff-member-title-value',''));
$cloned.html($cloned.html().replace('sstaff-member-email-value',''));
$cloned.html($cloned.html().replace('staff-member-role-value',''));
// Append the cloned HTML to the staffMemberList div.
$('#staffMemberList').append($cloned.html());
}
});</script>
What am I doing wrong. Thanks and appreciate it
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thansk guys I have updated my page link and here is the new one as you can see I have included jQuery but its not working
http://dev.acec-nh.org/Membership-Application/Membership-Application.html
Thanks again
http://dev.acec-nh.org/Membership-Application/Membership-Application.html
Thanks again
$('#staffMemberList').append($cloned.show());
Where is element staffMemberList in your document?Your code is trying to append something to an element that does not exist.
ASKER
Thanks
You at least need to change the code in your head from
Open in new window
to
Open in new window
Then we can take it from there.