By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,669 Members | 2,203 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,669 IT Pros & Developers. It's quick & easy.

Get form input total

P: 2
I am totally duh at javascript although I have 2 books trying to learn it.

I am trying to add values to a form and have a calculate total at end.
this is my form script. I have hours at end of each radio or checkmark. (If this is checked, add these hours. ) I want to calculate total at the calculate button at the bottom of the form and have a window that shows the total.

please excuse the long form, but with all the different variables I thought it wise to post whole thing.

[HTML]<form method="post" action="">
<fieldset name="General">
<legend class="alignleft">General</legend>
<p>
<input name="Have_Site" type="radio" checked="checked" />&nbsp;&nbsp;
I have an existing website.&nbsp; (0 hours)</p>
<p><input name="Have_Site" type="radio" />&nbsp;&nbsp;
I need a basic blog site.&nbsp; (3 hours)</p>
<p>
<input name="Have_Site" type="radio" />&nbsp;
I need a basic, off the shelf, template based site
set-up.&nbsp; (6 hours)</p>
<p><input name="Have_Site" type="radio" />&nbsp; I need a completely custom site.&nbsp; (15 hours)<br />
</p>
</fieldset>
<fieldset name="Site Layout">
<legend class="alignleft">Site Layout</legend>
<p>
<input name="No_Graphics" type="radio" checked="checked" />&nbsp;
I do not need any unique graphics designed.&nbsp;&nbsp;
(0 hours)</p>
<p><input name="Have_Graphics" type="radio" />&nbsp; I have all
my graphics but they need to be integrated. (3 hours)</p>
<p><input name="Template_Minor" type="radio" />&nbsp; I have a
template but it needs minor customization.&nbsp; (6
hours)</p>
<p><input name="Template_Major" type="radio" />&nbsp; I have a
template but it needs major custimzation.&nbsp; (10
hours)</p>
<p><input name="Custom_Design" type="radio" />&nbsp; I would
like a custom design created for my site.&nbsp; (20
hours)&nbsp;</p>
</fieldset>
<fieldset name="Other Graphics">
<legend class="alignleft">Other Graphics</legend>
<p><input name="Need_Custom_Graphics" type="checkbox" />&nbsp; I
need some custom graphics made.&nbsp; (4 hours)</p>
<p><input name="Mouse-over_Graphics" type="checkbox" />&nbsp; I
need graphic mouse-over buttons.&nbsp; (4 hours)</p>
<p><input name="Few_Stock" type="checkbox" />&nbsp;&nbsp; I
need a few stock photographs integrated.&nbsp; (4 hours)</p>
<p><input name="More_Stock" type="checkbox" />&nbsp;&nbsp; I
need several stock photographs integrated.&nbsp; (9
hours)</p>
</fieldset>
<fieldset name="Flash">
<legend class="alignleft">Flash</legend>
<p><input name="Flash_Menu" type="checkbox" />&nbsp; I
need a flash menu.&nbsp; (6 hours)</p>
<p><input name="Flash_Animation" type="checkbox" />&nbsp;&nbsp; I
need a short custom flash animation.&nbsp; (3 hours)</p>
<p><input name="Total_Flash" type="checkbox" />&nbsp;&nbsp; I
want my site in Flash for a total of&nbsp;
<select name="Select1">
<option></option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
</select>&nbsp; pages.&nbsp; (5 hours per page.)</p>
<p><input name="Flash_Banner" type="checkbox" />&nbsp;&nbsp; I
need a flash banner.&nbsp; (4 hours)</p>
</fieldset>
<fieldset name="Content">
<legend class="alignleft">Content</legend>
<p>
<input name="I_add_Content" type="radio" checked="checked" />&nbsp;
I will add my content with a content manager.&nbsp; (0
hours)</p>
<p><input name="Content_Pages" type="radio" />&nbsp;&nbsp; I will
supply <select name="Select2">
<option></option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
</select> pages of content in MS Word or Notepad text.&nbsp;
(3 hours per page)</p>
<p><input name="Copyrighting_Pages" type="checkbox" />&nbsp; I need
<select name="Select3">
<option></option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
</select> pages of copywriting done for my content.&nbsp;
(5 hours per page.<br /></p>
</fieldset>
<fieldset name="Public Features">
<legend class="alignleft">Public Features</legend>
<p><input name="Member_Registration" type="checkbox" />&nbsp;
Member Registration&nbsp; (6 hours)</p>
<p><input name="Discussion_Forum" type="checkbox" />&nbsp;&nbsp;
Discussion Forum&nbsp; (5 hours)</p>
<p><input name="Contact_Form" type="checkbox" />&nbsp;
Contact Form&nbsp; ( 3 hours)</p>
<p><input name="Links_Page" type="checkbox" />&nbsp;
Links Page&nbsp; (3 hours)</p>
<p><input name="Site_Search" type="checkbox" />&nbsp;
Site Search&nbsp; (4 hours)</p>
<p><input name="Auto-Responder" type="checkbox" />&nbsp;
Email Auto-responder (2 hours)</p>
<p><input name="File_Upload" type="checkbox" />&nbsp;
File upload ( 8 hours)</p>
</fieldset>
<fieldset name="Ecommerce">
<legend class="alignleft">Ecommerce</legend>
<p><input name="Simple_Cart" type="checkbox" />&nbsp;
Simple shopping cart&nbsp; (5 hours)</p>
<p><input name="Database_Cart" type="checkbox" />&nbsp;
Database shopping cart&nbsp; (10 hours)</p>
<p><input name="Credit_Card" type="checkbox" />&nbsp;
Credit Card Processing&nbsp; ( 4 hours)</p>
<p><input name="PayPal" type="checkbox" />&nbsp;
PayPal&nbsp; processing</p>
</fieldset>
<fieldset name="Admin_Features">
<legend class="alignleft">Admin Features</legend>
<p><input name="Blog" type="checkbox" />&nbsp; Off
the shelf Blog&nbsp; (3 hours)</p>
<p><input name="Custom_Blog" type="checkbox" />&nbsp;
Custom Site Blog&nbsp; (6 hours)</p>
<p><input name="Photo_Gallery" type="checkbox" />&nbsp;
Photo Gallery&nbsp; (6 hours)</p>
<p><input name="Member_Admin" type="checkbox" />&nbsp;
Member Administration&nbsp; (5 hours)</p>
<p><input name="Site_Statistics" type="checkbox" />&nbsp;
Site Statistics (1 hour)</p>
</fieldset>
<fieldset name="SEO">
<legend class="alignleft">SEO</legend>
<p><input name="MetaTag" type="checkbox" />&nbsp;
MetaTag Keyword Optimization (5 hours)</p>
<p><input name="Search_Engine_Submission" type="checkbox" />&nbsp;
Search Engine Submission (3 hours)</p>
<p><input name="Link_Building" type="checkbox" />&nbsp;
Minor Link Building (6 hours)</p>
</fieldset>

<br />
<input name="Calculate_Cost" type="button" value="Calculate Cost" /></form>[/HTML]
Aug 18 '08 #1
Share this Question
Share on Google+
1 Reply


acoder
Expert Mod 15k+
P: 16,027
Have you managed anything so far?

What I suggest you do is name the radio buttons with the same name for each section. That way you can access all of them in one go and then loop over them. Alternatively, use document.getElementsByTagName("input") to get all of the input elements on the page. Also add value attributes for each radio button that contains the hours figure. That would make it easier to add up the values.
Aug 19 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.