Hi, I'm very new to Prototype Javascript so any help would be greatly
appreciated.

My issue is this, I have a form that does calculations. At the bottom
of the form there is a button that when clicked updates the totals and
displays it at the bottom of the page. Here is the code for the
button.

 <input type="button" name="update" id="update" value="Update Total"
onclick="footprintcalc.total(); footprintcalc.addElement();" />

This button actually does 2 things totals the numbers in the form like
I mentioned above but also adds a hidden input box that also holds the
totals. Here is the piece of code that does that.

addElement: function () {
        var theNewElem = document.createElement('input');
        theNewElem.setAttribute('type', '');
        theNewElem.setAttribute('id', 'finaltons');
        theNewElem.setAttribute('value', totaltotal);
        document.getElementById('formtons').appendChild(theNewElem);
    }

};

This hidden input box with the id finaltons,  is used to set a session
variable which can be used to transfer my final total to another page.
This part is done in C#.

My problem is, if you hit the "Update Total" button multiple times I
get multiple hidden input box's which causes a problem with my session
variable. So what do I have to add to my code so it doesn't add the
input box if its already exists. Can this be done?

-- 
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.

Reply via email to