Results 1 to 4 of 4

Thread: Javascript Help

  1. #1
    Join Date
    Aug 2007
    Location
    Oakham England
    Posts
    503

    Javascript Help

    Hey,

    I cant get this JS to work, can anyone help me?

    HTML Code:
    <form>
    <ul class="addedfields">
    <li><input type="text" name="field[]" class="textbox" />
    <input type="button" class="removebutton" value="remove"/></li>
    </ul>
    <input type="button" class="addbutton" value="add"/>
    </form>
    
    
    <script language="javascript">
    
    $(function(){
      $(".addbutton").click(){
         if(".addedfields").length < 10){
           $(".addedfields").append(
             '<li><input type="text" name="field[]" class="textbox" />' + 
             '<input type="button" class="removebutton" value="remove"/></li>'
           );
         }
      }
    		   
    
      // live event will automatically be attached to every new remove button
      $(".removebutton").live("click",function(){
         $(this).parent().remove();
      });
    });
    
    </script>
    Streama - Your WordPress Friend
    http://www.streama.co.uk

  2. #2
    Can you show your page header?

  3. #3
    Assuming you have a proper header (loaded jQuery on HEAD tag), look for this line:
    Code:
    if(".addedfields").length < 10){
    You forgot to enclode it to "$" method. It must be:
    Code:
    if($(".addedfields").length < 10){
    It's best to use this (we are getting all list items and count it) - notice changes from "length" property to "size" method:
    Code:
    if($(".addedfields li").size() < 10){
    DomainWink - Shared Web and Reseller Hosting with 24/7 Customer Support
    cPanel with 1-Click Script Installs | Anytime Money Back Guarantee | Free 30 Days Trial, No CC Required
    Visit us: www.domainwink.com

  4. #4

Similar Threads

  1. Need javascript help
    By hoachen in forum Programming Discussion
    Replies: 3
    Last Post: 12-21-2005, 11:13 AM
  2. javascript function has no properties in javascript console
    By mrblack in forum Programming Discussion
    Replies: 2
    Last Post: 05-25-2005, 02:15 PM
  3. Javascript
    By pztup in forum Programming Discussion
    Replies: 5
    Last Post: 12-13-2004, 02:48 AM
  4. javascript help
    By ilyash in forum Programming Discussion
    Replies: 4
    Last Post: 04-12-2003, 11:08 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •