Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-23-2012, 12:22 AM   PM User | #1
daora
New to the CF scene

 
Join Date: May 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
daora is an unknown quantity at this point
Need help with my javascript Assignment

Hello everyone, i'm new here, i'm currently studying to become a web designer at my local college i've been given this assignment and i searched all over the net for solutions and no luck so I registered hear to ask for your knowledge and wisdom to assist me so that way I can understand it better. this is the assignment im working on, i'm listing the link to the pdf of my assignment.....and please to each solution list the task number for me too please. http://daora-d.com/pdf/Assignment.pdf


id appreciate it too.

Cheers

Daora
daora is offline   Reply With Quote
Old 05-23-2012, 12:41 AM   PM User | #2
xelawho
Senior Coder

 
xelawho's Avatar
 
Join Date: Nov 2010
Posts: 2,437
Thanks: 52
Thanked 453 Times in 451 Posts
xelawho will become famous soon enoughxelawho will become famous soon enough
Quote:
Originally Posted by daora View Post
please to each solution list the task number for me too please.
seriously? How are you planning on filling in this section:
I CERTIFY THAT THIS ASSIGNMENT TASK IS MY OWN WORK & I HAVE REFERENCED ALL MATERIALS USED FROM ALL OTHER SOURCES.

?

How about you post what you have done so far and the problems that you are having? That way you might actually learn something and probably won't be accused of cheating.
xelawho is offline   Reply With Quote
Old 05-23-2012, 01:29 AM   PM User | #3
daora
New to the CF scene

 
Join Date: May 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
daora is an unknown quantity at this point
Quote:
Originally Posted by xelawho View Post
seriously? How are you planning on filling in this section:
I CERTIFY THAT THIS ASSIGNMENT TASK IS MY OWN WORK & I HAVE REFERENCED ALL MATERIALS USED FROM ALL OTHER SOURCES.

?

How about you post what you have done so far and the problems that you are having? That way you might actually learn something and probably won't be accused of cheating.
I had a talk with the teacher and he said as long i comment on were I acquired the scripts from and have my own comments. so me asking for help on here will be no problem
daora is offline   Reply With Quote
Old 05-23-2012, 03:07 AM   PM User | #4
felgall
Master Coder

 
felgall's Avatar
 
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 5,447
Thanks: 0
Thanked 496 Times in 488 Posts
felgall is a jewel in the roughfelgall is a jewel in the roughfelgall is a jewel in the rough
So what code do you have so far.

No one here will write a script for you but we will help if you have at least tried to write some code and it doesn't quite work.
__________________
Stephen
Learn Modern JavaScript - http://javascriptexample.net/
Helping others to solve their computer problem at http://www.felgall.com/
felgall is offline   Reply With Quote
Old 05-23-2012, 05:44 AM   PM User | #5
daora
New to the CF scene

 
Join Date: May 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
daora is an unknown quantity at this point
Code:
<style>
	body{
		font-family:Verdana, Geneva, sans-serif;
		font-size:12px;
	}
	fieldset{
		width:512px;
	}
	table, td, th{
		padding:0px;
		margin:10px;
		border:none;
	}
	#sub{
		margin:0px;
	}
	th{
		vertical-align:text-top;
		text-align:right;
		padding-right:10px;
		font-weight:normal;
		width:100px;
	}
	.alt{
		background-color:#eee;
	}
	.errorBeans {
		display:none;
	}
	.errorType {
		display:none;
	}
	.errorName {
		display:none;
	}
	.errorAddress {
		display:none; 	
	}
	.errorCity {
		display:none;
		
	}
	.errorState {
		display:none;
	}
	.errorPost {
		display:none;
	}
    </style>
<script type="text/javascript" language="javascript">
function validate(beanForm)
			{
				errorflag=0
			}if document.getElementById(beans).value=true 
		
			return:false;}
			}
</script>
</head>

<body>
<h2>Task 3 – 15 Marks</h2>
<p style="font-weight:bold; color:black;">Create a form as described below with any relevant validation for StarBuzz’s coffee ordering page. Use the Html provided.</p>
<form id="beanForm">
	<fieldset><legend>The Starbuzz Bean Machine</legend>
	<table>
    	<tr class="alt">
        	<th>Choose your beans:</th>
            <td>
            	<select id="beans" name="beans">
                    <option value="House Blend">House Blend</option>
                    <option value="Bolivia">Shade Grown Bolivia Supremo</option>
                    <option value="Guatemala">Organitc Guatemala</option>
                    <option value="Kenya">Kenya</option>
    			</select><br />
 				<span class="errorBeans" style="color:red;">Please make a selection</span>
            </td>
        </tr>
        <tr>
        	<th>Type:</th>
            <td>
            	<label><input id="beantype" name="beantype" type="radio" value="whole" /> Whole Bean</label><br/>
    			<label><input id="beantype" name="beantype" type="radio" value="ground" /> Ground</label><br />
				<span class="errorType" style="color:red;" >Which bean would you like?</span>
    		</td>
        </tr>
        <tr class="alt">
        	<th>Extras:</th>
            <td>
            	<label><input id="extras[]" name="extras[]" type="checkbox" value="giftwrap" /> Gift Wrap</label><br/>
    			<label><input id="extras[]" name="extras[]" type="checkbox" value="catalog" /> Include a catalog</label>
            </td>
        </tr>
        <tr>
        	<th>Ship to:</th>
        	<td>
            	<table id="sub">
                	<tr>
                    	<td>Name:</td>
                        <td><input id="name" name="name" type="text" /><br />
						<span class="errorName" style="color:red;">Please enter your name</span></td>
                    </tr>
                    <tr>
                    	<td>Address:</td>
                        <td><input id="address" name="address" type="text" /><br />
						<span class="errorAddress" style="color:red;">Your address is required</span></td> <!-- The error will come up if there was no input added in the address link -->
                    </tr>
                    <tr>
                    	<td>City:</td>
                        <td><input id="city" name="city" type="text" /><br />

                        <span class="errorCity" style="color:red;">Please insert your city</span></td>
                    </tr>
                    <tr>
                    	<td>State:</td>
                        <td><input name="state" type="text" id="state" size="8" maxlength="8" /><br />
						<span class="errorState" style="color:red;">Please insert your state</span></td>
                    </tr>
                    <tr>
                    	<td>Post Code:</td>
                        <td><input name="zip" type="text" id="zip" size="4" maxlength="4" /><br />
						<span class="errorPost" style="color:red;">Incorrect values</span></td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr class="alt">
        	<th>comments:</th>
            <td>
            	<textarea id="comments" name="comments" cols="45" rows="10"></textarea>
            </td>
        </tr>
        <tr>
        	<td>&nbsp;</td>
            <td><input type="submit" value="Submit" onClick =""/></td>	
        </tr>
    </table>
	</fieldset>
</form>

</body>
</html>
This is what i tried to achieve so far.....but im all out of ideas i know it involves if statements but i dont know how to construct it.......i gave the attribute names for each value example name=beans.
daora is offline   Reply With Quote
Old 05-23-2012, 11:53 AM   PM User | #6
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,033
Thanks: 197
Thanked 2,410 Times in 2,388 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
In your beans select list you must supply a starting option (or make one choice pre-selected so that whatever happens an option is selected).

Code:
<option value = "0" >Choose a type of bean... >
and then in script

Code:
var val = document.beanForm.beans.value;
which will return the selected value. If that value == 0 then the user has not made a selection - try again. Obviously if one option is pre-selected then there is no need to make a check, but you still need to capture the value of the selection.

But your very limited Javascript code offering suggests that you really have little knowledge of Javascript.

Be aware that <seript language = "Javascript"> has been obsolete since 1997.
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Philip M is offline   Reply With Quote
Old 05-23-2012, 07:18 PM   PM User | #7
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,033
Thanks: 197
Thanked 2,410 Times in 2,388 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Quote:
Originally Posted by Old Pedant View Post
And this is completely wrong:

fahrenheit = (celsius * 8/6) + 46;

Maybe you should go look up the *correct* formula.
And maybe you should post in the right thread!

http://www.codingforums.com/showthread.php?t=262391
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Philip M is offline   Reply With Quote
Users who have thanked Philip M for this post:
Hashim1 (05-23-2012)
Old 05-23-2012, 07:49 PM   PM User | #8
Hashim1
Regular Coder

 
Join Date: Dec 2010
Location: Sheffield, UK
Posts: 136
Thanks: 81
Thanked 1 Time in 1 Post
Hashim1 is an unknown quantity at this point
Quote:
Originally Posted by Philip M View Post
Be aware that <seript language = "Javascript"> has been obsolete since 1997.
What do you mean by this, Philip M? Do you mean the script tags themselves have become obsolete?
__________________
http://www.topcashback.co.uk/ref/hashim1

^
Total earnings so far: £25.15
A very generous cashback site worth checking out.

Hashim1 is offline   Reply With Quote
Old 05-23-2012, 07:57 PM   PM User | #9
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,033
Thanks: 197
Thanked 2,410 Times in 2,388 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Quote:
Originally Posted by Hashim1 View Post
What do you mean by this, Philip M? Do you mean the script tags themselves have become obsolete?
No, of course not. Don't be silly! Surely you know this! It has been mentioned in this forum a zillion times!

<script language=javascript> is long deprecated (since 1997). Use <script type = "text/javascript"> instead (in fact also deprecated but still necessary for IE<9). The <!-- and //--> comment (hiding) tags have also not been necessary since IE3 (i.e. since September 1997). If you see these in some published script it is a warning that you are looking at ancient and perhaps unreliable code.
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Philip M is offline   Reply With Quote
Old 05-23-2012, 08:32 PM   PM User | #10
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,168
Thanks: 59
Thanked 3,993 Times in 3,962 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Quote:
Originally Posted by Philip M View Post
And maybe you should post in the right thread!

http://www.codingforums.com/showthread.php?t=262391
I guess the moderator moved it between the time I opened this thread and the time I posted.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:17 AM.


Advertisement
Log in to turn off these ads.