www.webdeveloper.com
Results 1 to 5 of 5

Thread: adding/deleting table rows of a form with Javascript

  1. #1
    Join Date
    Apr 2003
    Posts
    9

    adding/deleting table rows of a form with Javascript

    Hi,

    I'm doing a calculator with telephone rates and stuff using ASP and an access database. I'm trying to do it like this one:

    http://www.cpsconnections.co.uk/calculator.asp

    It's using this js file: http://www.cpsconnections.co.uk/js/calculator.js

    What happens on the calculator above is that everytime you insert an international rate it stays on the bottom table and you can remove it or add another one. Plus you can reset the values. I've tried reading the javascript code but it seems that im missing something since its an ASP page.

    Can anyone explain to me how this works or give me a link with a similar example?

    Thank you.

  2. #2
    Join Date
    Sep 2003
    Location
    Portsmouth, UK Occupation: Web Developer
    Posts
    2,602
    the js file u have is fine make sure the page the calculator is on has

    <form name="theForm" method="post" action="YOURPAGE" onSubmit="return checkValues();">
    caluclator bit in here

    <input type="submit" value="Add">
    </form>
    Richard Turner - A Virtual Insight

  3. #3
    Join Date
    Apr 2003
    Posts
    9
    I wish it was that simple. I have the form just like that. The problem seems to be elsewhere.

    If it helps the error that I get is "Object doesn't support this property or method". It hits on the line: document.theForm.submit();

  4. #4
    Join Date
    Sep 2003
    Location
    Portsmouth, UK Occupation: Web Developer
    Posts
    2,602
    have you checked the js files for references to divs or ids, tags and that like

    getElementByID("foo")

    then u will need

    <div id="foo"></div> in <body> of calculator
    Richard Turner - A Virtual Insight

  5. #5
    Join Date
    Apr 2003
    Posts
    9
    It would be nice if you or someone else could exlpain the code briefly or give me a similar example on the web. The parts that confuse me basically and where I think im doing something wrong, are those two functions:

    function deleteIt(rec, type){
    document.theForm.deltype.value = type;
    document.theForm.deleter.value = rec;
    document.theForm.submit();
    }

    This is called once I press the 'remove' or 'reset' link:

    <td a href="javaScript:deleteIt('0', 'international')" class="removeLink">remove</a></td>

    and this function
    function trim(s){

    while(s.indexOf(' ') == 0 || s.indexOf('\t') == 0 || s.indexOf('\r') == 0 || s.indexOf('\n') == 0){
    s = s.slice(1);}
    while(s.lastIndexOf(' ') == 0 || s.lastIndexOf('\t') == 0 || s.lastIndexOf('\r') == 0 || s.lastIndexOf('\n') == 0){
    s = s.slice(0, -1);}
    return s;

    }

    This is called when submiting the form and its inside the submitTheForm function

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles