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 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Oct 2008
    Location
    US
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Newbie needs HELP!

    I am trying to figure out javascript with 2 books I purchased with no luck. I have searched for weeks for a script on the internet that would work for me with no luck. I am posting what I have in my form and the javascript I have (it doesn't work) and maybe someone can tell me how to get this working before I pull all my hair out! If someone can recommend a JS book that will start from the beginning for javascript challenged minds I would appreciate that also.

    What I need is to take the radio box value and the checkbox values that are clicked and add them up at the bottom in a total box. I don't care whether the box total is by a button that adds them up at the click of the button, or it is a running total in the box.

    HTML page
    Code:
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Estimator</title>
    
    </head>
    <html>
    <body>
    <form method="post" action="" name="cost_estimator">
    					
    					
    						<fieldset name="General">
    						<legend class="alignleft">General</legend>
    					<p>
    					<input name="General" type="radio" checked="checked" value="0"onchange="Totals(this.form)"/>&nbsp;&nbsp; 
    					I have an existing website.&nbsp; (0 hours)</p>
    						<p><input name="General" type="radio" value="3" onchange="(Totals)"/>&nbsp;&nbsp; 
    						I need a basic blog site.&nbsp; (3 hours)</p>
    						<p>
    						<input name="General" type="radio" value="6" />&nbsp; I 
    						need a basic, off the shelf, template based site set-up.&nbsp; 
    						(6 hours)</p>
    					<p><input name="General" type="radio" value="1" />&nbsp; I 
    					need a completely custom site.&nbsp; (15 hours)<br />
    						</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>
    
    					<div>
    <div>
    
    						<input name="Totals" type="text" <script type="text/javascript" src="Totals.js"></script>Total Hours for your site<br />
    	</div>
    </form>
    
    
    </body>
    
    </html>
    the external script

    Code:
    function Totals(f)
    {
    var nums = f.num;
    var result = 0;
    for(var i=0;i++)
    {
    if(nums[i].checked)
    {
    result+=parseFloat(ntext[i].value);
    }
    }
    f.answer.value=result;
    
    }
    Last edited by tcertain; 10-17-2008 at 02:21 PM. Reason: brackets for code wrong

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    You need this: http://www.getFirebug.com

    Looks like you have variables that do not related to anything.

    I see no form field name num and I have no idea what ntext relates to.

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #3
    New to the CF scene
    Join Date
    Oct 2008
    Location
    US
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    As I said I am trying to use code off the internet and it doesn't work. Worse yet, I don't understand the script to fix it. Firebug won't write the code for me and I have no idea how to make any script work and I don't know how to script it myself.

    Any coding help would be greatly appreciated.

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,907
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    "As I said I am trying to use code off the internet and it doesn't work. Worse yet, I don't understand the script to fix it. Firebug won't write the code for me and I have no idea how to make any script work and I don't know how to script it myself."

    Your code contains a good many errors and it is asking a lot for other people to in effect do your (paid?) work for you. If you want to use computer code you really have to learn it. That would be true of any other subject - you would not say "I have no idea how to cook - so make me a meal". I have to say that your prospects as a self-employed web designer are not too bright if you lack this basic knowledge - same would go for a self-employed cook who could not tell an egg from a carrot.


    "If someone can recommend a JS book that will start from the beginning for javascript challenged minds I would appreciate that also."

    Google offers many possibilities, including

    http://www.w3schools.com/JS/default.asp

    Try and get hold of a book called "JavaScript in Easy Steps" by Mike McGrath.
    Published Computer Step www.ineasysteps.com.
    It is an excellent beginner's instruction book, and I am sure will answer all your questions. (Third Edition April 2006 is &#163;10.99 - but available from Amazon and bookshops across the world).

    Do please read the posting guidelines regarding silly thread titles. The thread title is supposed to help people who have a similar problem in future. Yours is useless for this purpose.
    Last edited by Philip M; 10-17-2008 at 04:51 PM.

  • #5
    New to the CF scene
    Join Date
    Oct 2008
    Location
    US
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Angry Sorry for asking.

    I was under the impression that forums were for people who do not understand the project and need help. My experience is with html/css and
    I do participate in a forum answering questions regarding such and sometimes give them the code to place in their page if they are newbies and don't understand what they are doing. Just because I don't know javascript doesn't mean I can't design a website. It just means I am learning something new.

    The biggest problem with forums are they think people that ask questions should know what they are doing, and guess what? If they knew they wouldn't be asking!


  •  

    Posting Permissions

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