Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    mjs
    mjs is offline
    New Coder
    Join Date
    Jan 2010
    Posts
    97
    Thanks
    17
    Thanked 0 Times in 0 Posts

    function remove doesn't work, please help...

    Hi, If someone here is willing to help me I would really appreciate

    the function removeInput() of javascript at below not work properly, what i should do?

    Code:
    <script language="javascript">
    fields = 0;
    function addInput() {
        if (fields != 10) {
            var htmlText =  "<input type='text' name='friends[]' value='' size='auto' maxlength='45' /><br />";
            var newElement = document.createElement('div');
            newElement.id = 'addfriend'; 
    	 newElement.innerHTML = htmlText;
    
            var fieldsArea = document.getElementById('addfriend');
    	fieldsArea.appendChild(newElement);
    
            fields += 1;
        } else {
            alert("Only 10 friends allowed.");
            document.form.add.disabled=true;
        }
    }
    //field = 0;
    function removeInput() {
    		var div = document.getElementById('addfriend');
            var lastElement = document.removeElement('div');
            lastElement.id = 'addfriend'; 
    		if (lastElement > 2) div.Element(lastElement - 1);
    
    }
    </script>
    Thanks a lots
    Last edited by mjs; 10-31-2010 at 04:49 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
  •