Hi I have a problem with my javascript the functions are not working, and I have a little
knowledge about JScript.
Firstly, the user will select from the list box a designer name, then a flower,
and then a cake. The total will come up when the user clicks on check price. Or
i can deleted the check price button i can automatically add items there as they select.
I have tried my best even worked with my friend to solve the problem however it still
isnt working!! Dont know where the problem is!
And when the user doesnt check the terms and conditions and click Proceed it will give
an error saying Please accept the terms and conditons...and if the user checks the box and
everything is fine the user will get their name which is message1 and contact number message 2
the items chosen and product total as u can see at the function stage i have declared if function!
It still doesnt work...
I am so used to Visual Basic, and this is new to me.
Could someone please help me to solve the problem?
Thank you in advance
<html>
<head>
<title>Online Store</title>
<script language="javascript">
<!--
var proceeed=0;
function getRadioValue(radioArray)
{
var i
for (i = 0; i < radioArray.lenght; i++)
{
if (radioArray[i].checked) return radioArray[i].value
}
return ""
}
function getSelectedText(selectList) {
return selectList.option[selectList.selectedIndex].text
}
function getSelectedValue(selectList) {
return selectList[selectList.selectedIndex].value;
}
function view(form)
{
var designertype=getSelectedText(form.designer);
var message1=form.message1.value;
var message2=form.message2.value;
var flowertype=getRadioValue(form.flower);
var caketype=getRadioValue(form.cake);
var totalprice=0;
totalprice=designertype+caketype+flowertype;
if(message1 && message2 != "")
{
alert("Please enter your Personal Details and Contact Number!");
}
else
{
themessage= "Thank you: " + form.message1.value + " . We will contact you shortly from : " + form.message2.value + ";
}
form.price.value=totalprice;
if (proceed==1)
{
if (!form.terms.checked)
{
alert("You must read and accept the terms and conditions");
}
else
{
confirm("You have ordered a " + designertype + " dress, " + flowertype + " flower, " + caketype + " cake. \nThe total price is: " + totalprice + " .\n");
}
}
}
//--!>
</script>
</head>
<body>
<table border="0" width="65%">
<tr>
<td colspan="4">
<a name="tp"><img border="0" src="finalbanner.jpg" width="919" height="242" align="right" /></td>
</tr>
<tr>
<td width="73%" colspan="4">
<p align="left"> <b><font color="#FF00FF">
<font face="Verdana" size="2">
<a href="http://users.wmin.ac.uk/~w1176770/coursework/intro.html" style="text-decoration: none"><font color="#FF00FF">Introduction</font></a>
<a href="topMainPage.html" style="text-decoration: none"><font color="#FF00FF">Main Page</font></a>
<a href="#" onMouseover="showmenu(event,linkset[1], '180px')" onMouseout="delayhidemenu()" style="tex\t-decoration: none">Go To Store</a>
<a href="http://users.wmin.ac.uk/~w1176770/coursework/feedback.html" style="text-decoration: none"><font color="#FF00FF">Feed Back</font></a>
<a href="http://users.cscs.wmin.ac.uk/~w1182867/sfe407/cw/resumes.html" style="text-decoration: none"> <font color="#FF00FF">Resumes</font></a>
<a href="quiz.html" style="text-decoration: none"><font color="#FF00FF">Quiz</font></a>
<a href="contact.html" style="text-decoration: none"><font color="#FF00FF"> Contact</font><font face="Brush Script MT" size="4"> </font></b> </td>
</tr>
<tr>
<td width="99%" height="23" align="center" colspan="4" bgcolor="#0000FF">
<b><font face="Verdana" size="2" color="#FFFFFF"><blink>Now you are in the Go To Store Page</blink></font></b></td>
</tr>
<tr>
</table>
<b>Welcome to our online store.<b><br />
Here below you can choose the wedding dress designer, flower, and even the cake!
<br />
The system will automatically give you a total price for the items you have chosen.<br /> Please include your personal details so we can contact
you to confirm the order and take payment and delivery details.<br />
<br />
Thank you for shopping with us.<br />
<form>
<table border="5" cellpadding="10" cellspacing="4" bgcolor="DA70D6" width="56%">
<tr>
<td colspan="2"> <h3>Please choose the dress designer:</h3>
<select name="designer" onChange="view(this.form)">
<option value = 0 > </option>
<option value = 700>Alice James 2008</option>
<option value = 710>Allie Renee</option>
<option value = 720>Annette Carey Couture 2008</option>
<option value = 730>Benjamin Roberts 2008</option>
<option value = 740>Berkertex at Littlewoods</option>
<option value = 750>Berketex Bride</option>
<option value = 760>Blue by Enzoani</option>
<option value = 770>Cameron Blake</option>
<option value = 780>Caroline Castigliano</option>
<option value = 790>Constantina</option>
<option value = 800>Constantina by Enzoani</option>
<option value = 810>Dessy Collection 2009</option>
<option value = 820>Dessy Girl - Flowergirls 2009</option>
<option value = 830>Dessy Sandals 2009</option>
<option value = 840>Eternity Bride</option>
<option value = 850>Evenings by Mon Cheri</option>
<option value = 860>Impression Bridal</option>
<option value = 870>Justin Alexander</option>
<option value = 880>Kosibah Creations</option>
<option value = 900>Le Gala</option>
</select>
</td>
</tr>
<td colspan="2"bgcolor="white"> <h3>Please choose the flower:</h3>
<input type="radio" name="flower" value="40"
onClick="view(this.form)">
<img src="flower1.jpg" width="90" align"middle">
<input type="radio" name="flower" value="45"
onClick="view(this.form)">
<img src="flower2.jpg" width="90" align"middle">
<input type="radio" name="flower" value="50"
onClick="view(this.form)">
<img src="flower3.jpg" width="90" align"middle">
<input type="radio" name="flower" value="40"
onClick="view(this.form)">
<img src="flower4.jpg" width="90" align"middle">
<input type="radio" name="flower" value="30"
onClick="view(this.form)">
<img src="flower5.jpg" width="90" align"middle"><br />
<input type="radio" name="flower" value="40"
onClick="view(this.form)">
<img src="flower6.jpg" width="90" align"middle">
<input type="radio" name="flower" value="45"
onClick="view(this.form)">
<img src="flower7.jpg" width="90" align"middle">
<input type="radio" name="flower" value="30"
onClick="view(this.form)">
<img src="flower8.jpg" width="90" align"middle">
<input type="radio" name="flower" value="50"
onClick="view(this.form)">
<img src="flower9.jpg" width="90" align"middle">
<input type="radio" name="flower" value="50"
onClick="view(this.form)">
<img src="flower10.jpg" width="90" align"middle">
</td>
</tr>
<tr>
<td bgcolor="white"> <h3>Please choose the cake:</h3>
<input type="radio" name="cake" value="50"
onClick="view(this.form)">
<img src="cake1.jpg" width="90" align"middle">
<input type="radio" name="cake" value="50"
onClick="view(this.form)">
<img src="cake2.jpg" width="90" align"middle">
<input type="radio" name="cake" value="50"
onClick="view(this.form)">
<img src="cake3.jpg" width="90" align"middle"><br />
<input type="radio" name="cake" value="50"
onClick="view(this.form)">
<img src="cake4.jpg" width="90" align"middle">
<input type="radio" name="cake" value="50"
onClick="view(this.form)">
<img src="cake5.jpg" width="90" align"middle">
<input type="radio" name="cake" value="50"
onClick="view(this.form)">
<img src="cake6.jpg" width="90" align"middle">
</td>
<td width="10%">
<h3>Personal Details:</h3>
<h4>First & Last Name:
<input type="text" name="message1" size="30">
Contact Number:
<input type="number" name="message2" size="11">
</h4>
</td>
</tr>
<tr>
<td colspan="2">
<b>Total Price: £</b>
<input type="text" name="price" size="4">
<input type="button" value="check price" onClick="view(this.form)"> <br />
</td>
</tr>
<tr>
<td colspan="2" >
<input type="checkbox" name="terms" value="read" >
<b>I have read and accepted the <ahref="tac.html">terms and conditions</a></b> <br />
<br />
<input type="button" name="proceed" value="Proceed with order" onClick="proceed=1;view(this.form)">
</td>
</tr>
</form>
</body>
</html>