# [RESOLVED] New to JavaScript totally stumped

• 09-26-2013, 08:33 AM
newcodette
[RESOLVED] New to JavaScript totally stumped
Hi everyone :)

I am trying to build a JavaScript form using radio buttons and trying to achieve a
watering time calculator using 2 sets of information.
1. 4 different systems
2. 3 different types

All systems + type1 = the variable totals represented below
All systems + type2 = are multiplied by 2
All systems + type 3 = are multiplied by 3.5
If the 'largeplants' check box is selected the total needs to be multiplied by 1.5

The calculateTime function needs to calculate the watering time on click & display an alert box stating the watering time
& The reset button needs to reset the radio buttons.

<!doctype html>
<html>
<meta charset="utf-8">
<title>Perfect Watering Results</title>

<script>

//Calculate Watering Time for Plants
function calculateTime (){
var system1 = 6; //watering time for sand with jetspray
var system2 = 11;//watering time for sand with sprinkler
var system3 = 17;//watering time for sand wih minisprinker
var system4 = 50; //watering time for sand with dripper

var largeplants = * 1.5; //multiply by 1.5 if checkbox is selected

var type1 //watering time for sand with all systems
var type2 = * 2; //watering time for loam with jetspray/sprinkler/minisprinker/dripper
var type3 = * 3.5;//watering time for clay with jetspray/sprinkler/minisprinker/dripper

// Get the number of the selected answer (1, 2, 3 or 4)
for (var i = 1; i <= 4; i++) {

// Get the number of the selected answer (1, 2, or 3)
for (var i = 1; i <= 3; i++) {

}

</script>

<body>
<h1>Home Garden Watering Guide</h1>
<p>Complete the form below to calculate the recommended watering time for your home garden.<br>
<br>
<br>
<form>
<p>Watering System</p>
<label for="jet">Jet Spray</label><br>
<label for="sprink">Sprinkler</label><br>
<label for="mini">Mini Sprinkler</label>
<br>
<label for="drip">Dripper</label>
</p>
</p>
</form>
<form>
<input type="checkbox" id="largeplants" name="plants"
value="largeplants" onClick=" * 1.5 ">
</form>

<form>
<p>Soil Type</p>
<label for="sand">Sand</label><br>
<label for="loam">Loam</label><br>
<label for="clay">Clay</label></form>
<br><br>
<input type="submit" value="Calculate" id="calculateTime"
onClick="calculateTime" alert("The recommended watering time is "" minutes"> <input type="reset" value="Reset">
</body>
</html>

I know I haven't got through much so any and all help and hits to achieving this will be greatly appreciated.
Also please clarify if I do need to use a loop in this instance :)

Thanks heaps
• 09-26-2013, 08:44 AM
vwphillips

## X vBulletin 4.2.2 Debug Information

• Page Generation 0.08764 seconds
• Memory Usage 2,364KB
• Queries Executed 11 (?)
Template Usage (19):
• (1)footer
• (1)gobutton
• (1)navbar_moderation
• (1)navbar_noticebit
• (2)option
• (1)spacer_close
• (1)spacer_open

Phrase Groups Available (3):
• global
• postbit
Included Files (19):
• ./global.php
• ./includes/class_bootstrap.php
• ./includes/init.php
• ./includes/class_core.php
• ./includes/config.php
• ./includes/functions.php
• ./includes/class_friendly_url.php
• ./includes/class_hook.php
• ./includes/class_bootstrap_framework.php
• ./vb/vb.php
• ./vb/phrase.php
• ./includes/functions_calendar.php
• ./includes/class_bbcode_alt.php
• ./includes/class_bbcode.php
• ./includes/functions_bigthree.php
• ./includes/functions_notice.php

Hooks Called (41):
• init_startup
• init_startup_session_setup_start
• database_pre_fetch_array
• database_post_fetch_array
• init_startup_session_setup_complete
• global_bootstrap_init_start
• global_bootstrap_init_complete
• cache_permissions
• fetch_foruminfo
• global_state_check
• global_bootstrap_complete
• global_start
• style_fetch
• global_setup_complete
• bbcode_fetch_tags
• bbcode_create
• bbcode_parse_start
• bbcode_parse_complete_precache
• bbcode_parse_complete
• cache_templates
• cache_templates_process
• template_register_var
• template_render_output
• fetch_template_start
• fetch_template_complete
• parse_templates