Jump to content

Archived

This topic is now archived and is closed to further replies.

Freedom-n-Democrazy

If client submits value higher than X, then return false

Recommended Posts

Lets say I have a MySQL value of 4... and I have a HTML INPUT field.. Is there a way to make it so that if a client tries to submit a value higher than 4, then they will be returned a message? Something like:

 

<SCRIPT type="text/javascript">
function validateForm() {
	if (document.forms["form"]["quantity"].value== (+$row['quantity']) {
		alert ("Cannot submit because the quantity specified is not available.");
		return false;
	}
}
</SCRIPT>
<INPUT name="quantity">

Share this post


Link to post
Share on other sites

if(isset($_POST['submit'])){
   if($_POST['input'] > 4){
      $errors[] = "Value cannot be greater than 4!";
   }else{
      // proceed with form validation
   }
   if(!empty($errors)){
      foreach($errors as $error){
         echo $error."<br />".;
      }
   }
}

the same logic can be applied to javascript code..

 

EDIT: javascript method.. you can set the input an id and grab the value.

 

function validateForm() {
	if (document.getElementById('input').value > 4) {
		alert ("Cannot submit because the quantity specified is not available.");
		return false;
	}
}

however, it seems now that the 4 will not be static.. is the value dependent on the mysql value? if so, PHP will be the way to go here.. which is the language that I recommend you use to validate forms in the first place..

Share this post


Link to post
Share on other sites

var integer = parseInt(document.getElementById('id').value);
if (integer > 4)
   {   fail message   }
else {   submit.form   }

 

You have to parse the string coming in so that javascript understands that it is just dealing with just numbers and then you can treat it as you wish using mathematics.

Share this post


Link to post
Share on other sites

I tried this, but the page just went ahead and submitted:

 

Javascript:

function validateForm() {
var integer = parseInt (document.forms["form"]["quantity"].value);
$noavailability = $row['sizes'] + 1;
if (integer > $noavailability) {
	alert ("Cannot submit because quantity exceeds availability.");
	return false;
}
}

 

HTML

<INPUT class="quantity" name="quantity" value="1">

Share this post


Link to post
Share on other sites

can we see the full form.

how are you calling this function?

Share this post


Link to post
Share on other sites

Sure,

 

This is everything related to the script in regards to the quantity validation.

 

<?php
$link = mysql_connect('localhost', 'testusr', 'testpw');
mysql_select_db('testdb', $link);
$query = "select * from products where id='$id'"; $result = mysql_query($query); $row = mysql_fetch_array($result);
mysql_query ($query);
mysql_close($link);
?>

<SCRIPT type="text/javascript">
function validateForm() {
	if (document.forms["form"]["quantity"].value=="") {
		alert ("Cannot submit because a quantity has not been specified.");
		return false;
	}
	var integer = parseInt (document.forms["form"]["quantity"].value);
	if (integer > <?php echo $row['sizes']; ?>) {
		alert ("Cannot submit because quantity exceeds availability.");
		return false;
	}
	if (document.forms["form"]["size"].value=="") {
		alert ("Cannot submit because a size has not been selected.");
		return false;
	}
}
</SCRIPT>

<FORM action="../../../../cart/addtocart.html" method="post" name="form" onsubmit="return validateForm()">
<DIV>
	Add <INPUT class="quantity" name="quantity" value="1"> <SELECT class="size" name="size"><OPTION>Small</OPTION><OPTION>Large</OPTION></SELECT> to <INPUT class="cart" type="submit" value="CART"><INPUT name="id" type="hidden" value="<?php echo $id; ?>">
</DIV>
</FORM>

Share this post


Link to post
Share on other sites

Where is $row defined? Can you see it's value when you view the html source of your script?

Share this post


Link to post
Share on other sites

Sorry, I see it now. terrible way to execute your queries. You haven't checked that anything has succeeded and simply assume it has.

Share this post


Link to post
Share on other sites

Something tells me that $row['sizes'] is probably not the quantity.

Share this post


Link to post
Share on other sites

Still, your code assumes your query has succeeded. This is never a good way to program. If a function returns a value, check that it is what you expect before using it. Always.

Share this post


Link to post
Share on other sites

Yeah, I don't care about best practices. I only care about trying to get this validation thing working - which is what this thread is about.

People don't seem to be able to have a normal conversation. I am not here for a lecture of the way I code.

 

I'm not replying to anything thats not on topic.

Share this post


Link to post
Share on other sites

okay i'll be less blunt. As a programmer you must care about which ways to go about things.. if you simply throw something together and say "hey it works so i don't care", that will never get you anywhere and I can almost guarantee you it will lead to problems in the future.. Thorpe is trying to help both you and your methods.. if you don't want our help then you should simply figure it out on your own like the rest of us.. correct?

 

Edit: I have actually helped you on at least one of your threads.. this is a volunteer forum.. we take time out of our day to help you and you are not thankful for it.. if you don't want/need our help, why are you here?

Share this post


Link to post
Share on other sites

Don't bite the hand that feeds you.

Share this post


Link to post
Share on other sites

now let's get back on track.. have you looked at a view source to make sure that you php value is what you expect it to be?

 

Share this post


Link to post
Share on other sites

F-n-Domocrazy, it is you who assumes too much. We only see the information you supply in your posts. You are not even clear yourself on what column you wanted to use in your code. From the start of this thread -

 

if (document.forms["form"]["quantity"].value== (+$row['quantity']) {

 

BTW - Different sizes and colors of a product are different product ids. Your code would be so much simpler. Your current code has no way of testing the correct quantity column value.

Share this post


Link to post
Share on other sites

I just tried this, but doesn't work either.. just submits:

 

if (document.forms["form"]["quantity"].value = > <?php echo $row['sizes']; ?>) {
alert ("Cannot submit because quantity exceeds availability.");
return false;
}

Share this post


Link to post
Share on other sites

Again, have you looked at a view source to make sure that you php value is what you expect it to be?

Share this post


Link to post
Share on other sites

The source code:

 

if (document.forms["form"]["quantity"].value = > ) {
alert ("Cannot submit because quantity exceeds availability.");
return false;
}

 

The value is not showing! Why!

 

Do you want me to dump the entire source code into a CODE box?

Share this post


Link to post
Share on other sites

first step here would be to make sure that your query is doing what you want it to do..

 

$query = "select * from products where id='$id'";
$result = mysql_query($query); 
$row = mysql_fetch_array($result);

 

in your query, where is $id coming from?

try echoing $sql

try adding $result = mysql_query($result) or die(mysql_error()); for testing purposes

Share this post


Link to post
Share on other sites

Full source:

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"

        "http://www.w3.org/TR/html4/strict.dtd">

<TITLE></TITLE>

<META content="charset=windows-1252;text/html" http-equiv="content-type">

<LINK href="../../../../body.css" rel="stylesheet" type="text/css">

<STYLE type="text/css">

DIV.path {

	left: 50%;

	margin-left: -630px;

	margin-top: -313px;

	position: absolute;

	top: 50%

}

A.gold {

	color: rgb(255,215,0)

}

DIV.imagearea {

	left: 50%;

	margin-left: -439px;

	margin-top: -251px;

	position: absolute;

	top: 50%

}

DIV.imageselector {

	margin-bottom: 5px;

	text-align: center

}

SPAN.glance {

	color: rgb(255,215,0);

	cursor: text

}

SPAN.front {

	color: silver;

	cursor: pointer

}

SPAN.back {

	color: silver;

	cursor: pointer

}

SPAN.left {

	color: silver;

	cursor: pointer

}

SPAN.right {

	color: silver;

	cursor: pointer

}

SPAN.top {

	color: silver;

	cursor: pointer

}

SPAN.bottom {

	color: silver;

	cursor: pointer

}

IMG.glance {

	display: block

}

IMG.front {

	display: none

}

IMG.back {

	display: none

}

IMG.left {

	display: none

}

IMG.right {

	display: none

}

IMG.top {

	display: none

}

IMG.bottom {

	display: none

}

IMG.small {

	display: none

}

IMG.medium {

	display: none

}

IMG.large {

	display: none

}

IMG.extralarge {

	display: none

}

DIV.dimensionsselector {

	margin-top: 5px;

	text-align: center

}

SPAN.small {

	color: silver;

	cursor: pointer

}

SPAN.medium {

	color: silver;

	cursor: pointer

}

SPAN.large {

	color: silver;

	cursor: pointer

}

SPAN.extralarge {

	color: silver;

	cursor: pointer

}

DIV.productinformation {

	left: 50%;

	margin-left: 166px;

	margin-top: -226px;

	position: absolute;

	top: 50%

}

DIV.options {

	left: 50%;

	margin-left: -96px;

	margin-top: 89px;

	position: absolute;

	top: 50%;

	width: 346px

}

DIV.sizeavailability {

	margin-left: 151px

}

INPUT.quantity {

	width: 10px

}

</STYLE>

<?php

$link = mysql_connect('localhost', 'testusr', 'testpw');

mysql_select_db('testdb', $link);

$query = "select * from products where id='$id'"; $result = mysql_query($query); $row = mysql_fetch_array($result);

mysql_query ($query);

mysql_close($link);
?>
<SCRIPT type="text/javascript">

function glancetextjavascript() {

	document.getElementById("glancetext").style.color = "rgb(255,215,0)";

	document.getElementById("glancetext").style.cursor= "text";

	document.getElementById("fronttext").style.color= "silver";

	document.getElementById("fronttext").style.cursor= "pointer";

	document.getElementById("backtext").style.color= "silver";

	document.getElementById("backtext").style.cursor= "pointer";

	document.getElementById("lefttext").style.color= "silver";

	document.getElementById("lefttext").style.cursor= "pointer";

	document.getElementById("righttext").style.color= "silver";

	document.getElementById("righttext").style.cursor= "pointer";

	document.getElementById("toptext").style.color= "silver";

	document.getElementById("toptext").style.cursor= "pointer";

	document.getElementById("bottomtext").style.color= "silver";

	document.getElementById("bottomtext").style.cursor= "pointer";

	document.getElementById("smalltext").style.color= "silver";

	document.getElementById("smalltext").style.cursor= "pointer";

	document.getElementById("mediumtext").style.color= "silver";

	document.getElementById("mediumtext").style.cursor= "pointer";

	document.getElementById("largetext").style.color= "silver";

	document.getElementById("largetext").style.cursor= "pointer";

	document.getElementById("extralargetext").style.color= "silver";

	document.getElementById("extralargetext").style.cursor= "pointer";

}

function fronttextjavascript() {

	document.getElementById("glancetext").style.color= "silver";

	document.getElementById("glancetext").style.cursor= "pointer";

	document.getElementById("fronttext").style.color = "rgb(255,215,0)";

	document.getElementById("fronttext").style.cursor= "text";

	document.getElementById("backtext").style.color= "silver";

	document.getElementById("backtext").style.cursor= "pointer";

	document.getElementById("lefttext").style.color= "silver";

	document.getElementById("lefttext").style.cursor= "pointer";

	document.getElementById("righttext").style.color= "silver";

	document.getElementById("righttext").style.cursor= "pointer";

	document.getElementById("toptext").style.color= "silver";

	document.getElementById("toptext").style.cursor= "pointer";

	document.getElementById("bottomtext").style.color= "silver";

	document.getElementById("bottomtext").style.cursor= "pointer";

	document.getElementById("smalltext").style.color= "silver";

	document.getElementById("smalltext").style.cursor= "pointer";

	document.getElementById("mediumtext").style.color= "silver";

	document.getElementById("mediumtext").style.cursor= "pointer";

	document.getElementById("largetext").style.color= "silver";

	document.getElementById("largetext").style.cursor= "pointer";

	document.getElementById("extralargetext").style.color= "silver";

	document.getElementById("extralargetext").style.cursor= "pointer";

}

function backtextjavascript() {

	document.getElementById("glancetext").style.color= "silver";

	document.getElementById("glancetext").style.cursor= "pointer";

	document.getElementById("fronttext").style.color= "silver";

	document.getElementById("fronttext").style.cursor= "pointer";

	document.getElementById("backtext").style.color = "rgb(255,215,0)";

	document.getElementById("backtext").style.cursor= "text";

	document.getElementById("lefttext").style.color= "silver";

	document.getElementById("lefttext").style.cursor= "pointer";

	document.getElementById("righttext").style.color= "silver";

	document.getElementById("righttext").style.cursor= "pointer";

	document.getElementById("toptext").style.color= "silver";

	document.getElementById("toptext").style.cursor= "pointer";

	document.getElementById("bottomtext").style.color= "silver";

	document.getElementById("bottomtext").style.cursor= "pointer";

	document.getElementById("smalltext").style.color= "silver";

	document.getElementById("smalltext").style.cursor= "pointer";

	document.getElementById("mediumtext").style.color= "silver";

	document.getElementById("mediumtext").style.cursor= "pointer";

	document.getElementById("largetext").style.color= "silver";

	document.getElementById("largetext").style.cursor= "pointer";

	document.getElementById("extralargetext").style.color= "silver";

	document.getElementById("extralargetext").style.cursor= "pointer";

}

function lefttextjavascript() {

	document.getElementById("glancetext").style.color= "silver";

	document.getElementById("glancetext").style.cursor= "pointer";

	document.getElementById("fronttext").style.color= "silver";

	document.getElementById("fronttext").style.cursor= "pointer";

	document.getElementById("backtext").style.color= "silver";

	document.getElementById("backtext").style.cursor= "pointer";

	document.getElementById("lefttext").style.color = "rgb(255,215,0)";

	document.getElementById("lefttext").style.cursor= "text";

	document.getElementById("righttext").style.color= "silver";

	document.getElementById("righttext").style.cursor= "pointer";

	document.getElementById("toptext").style.color= "silver";

	document.getElementById("toptext").style.cursor= "pointer";

	document.getElementById("bottomtext").style.color= "silver";

	document.getElementById("bottomtext").style.cursor= "pointer";

	document.getElementById("smalltext").style.color= "silver";

	document.getElementById("smalltext").style.cursor= "pointer";

	document.getElementById("mediumtext").style.color= "silver";

	document.getElementById("mediumtext").style.cursor= "pointer";

	document.getElementById("largetext").style.color= "silver";

	document.getElementById("largetext").style.cursor= "pointer";

	document.getElementById("extralargetext").style.color= "silver";

	document.getElementById("extralargetext").style.cursor= "pointer";

}

function righttextjavascript() {

	document.getElementById("glancetext").style.color= "silver";

	document.getElementById("glancetext").style.cursor= "pointer";

	document.getElementById("fronttext").style.color= "silver";

	document.getElementById("fronttext").style.cursor= "pointer";

	document.getElementById("backtext").style.color= "silver";

	document.getElementById("backtext").style.cursor= "pointer";

	document.getElementById("lefttext").style.color= "silver";

	document.getElementById("lefttext").style.cursor= "pointer";

	document.getElementById("righttext").style.color = "rgb(255,215,0)";

	document.getElementById("righttext").style.cursor= "text";

	document.getElementById("toptext").style.color= "silver";

	document.getElementById("toptext").style.cursor= "pointer";

	document.getElementById("bottomtext").style.color= "silver";

	document.getElementById("bottomtext").style.cursor= "pointer";

	document.getElementById("smalltext").style.color= "silver";

	document.getElementById("smalltext").style.cursor= "pointer";

	document.getElementById("mediumtext").style.color= "silver";

	document.getElementById("mediumtext").style.cursor= "pointer";

	document.getElementById("largetext").style.color= "silver";

	document.getElementById("largetext").style.cursor= "pointer";

	document.getElementById("extralargetext").style.color= "silver";

	document.getElementById("extralargetext").style.cursor= "pointer";

}

function toptextjavascript() {

	document.getElementById("glancetext").style.color= "silver";

	document.getElementById("glancetext").style.cursor= "pointer";

	document.getElementById("fronttext").style.color= "silver";

	document.getElementById("fronttext").style.cursor= "pointer";

	document.getElementById("backtext").style.color= "silver";

	document.getElementById("backtext").style.cursor= "pointer";

	document.getElementById("lefttext").style.color= "silver";

	document.getElementById("lefttext").style.cursor= "pointer";

	document.getElementById("righttext").style.color= "silver";

	document.getElementById("righttext").style.cursor= "pointer";

	document.getElementById("toptext").style.color = "rgb(255,215,0)";

	document.getElementById("toptext").style.cursor= "text";

	document.getElementById("bottomtext").style.color= "silver";

	document.getElementById("bottomtext").style.cursor= "pointer";

	document.getElementById("smalltext").style.color= "silver";

	document.getElementById("smalltext").style.cursor= "pointer";

	document.getElementById("mediumtext").style.color= "silver";

	document.getElementById("mediumtext").style.cursor= "pointer";

	document.getElementById("largetext").style.color= "silver";

	document.getElementById("largetext").style.cursor= "pointer";

	document.getElementById("extralargetext").style.color= "silver";

	document.getElementById("extralargetext").style.cursor= "pointer";

}

function bottomtextjavascript() {

	document.getElementById("glancetext").style.color= "silver";

	document.getElementById("glancetext").style.cursor= "pointer";

	document.getElementById("fronttext").style.color= "silver";

	document.getElementById("fronttext").style.cursor= "pointer";

	document.getElementById("backtext").style.color= "silver";

	document.getElementById("backtext").style.cursor= "pointer";

	document.getElementById("lefttext").style.color= "silver";

	document.getElementById("lefttext").style.cursor= "pointer";

	document.getElementById("righttext").style.color= "silver";

	document.getElementById("righttext").style.cursor= "pointer";

	document.getElementById("toptext").style.color= "silver";

	document.getElementById("toptext").style.cursor= "pointer";

	document.getElementById("bottomtext").style.color = "rgb(255,215,0)";

	document.getElementById("bottomtext").style.cursor= "text";

	document.getElementById("smalltext").style.color= "silver";

	document.getElementById("smalltext").style.cursor= "pointer";

	document.getElementById("mediumtext").style.color= "silver";

	document.getElementById("mediumtext").style.cursor= "pointer";

	document.getElementById("largetext").style.color= "silver";

	document.getElementById("largetext").style.cursor= "pointer";

	document.getElementById("extralargetext").style.color= "silver";

	document.getElementById("extralargetext").style.cursor= "pointer";

}

function glanceimagejavascript() {

	document.getElementById('glanceimage').style.display='block';

	document.getElementById('frontimage').style.display='none';

	document.getElementById('backimage').style.display='none';

	document.getElementById('leftimage').style.display='none';

	document.getElementById('rightimage').style.display='none';

	document.getElementById('topimage').style.display='none';

	document.getElementById('bottomimage').style.display='none';

	document.getElementById('smallimage').style.display='none';

	document.getElementById('mediumimage').style.display='none';

	document.getElementById('largeimage').style.display='none';

	document.getElementById('extralargeimage').style.display='none';

}

function frontimagejavascript() {

	document.getElementById('glanceimage').style.display='none';

	document.getElementById('frontimage').style.display='block';

	document.getElementById('backimage').style.display='none';

	document.getElementById('leftimage').style.display='none';

	document.getElementById('rightimage').style.display='none';

	document.getElementById('topimage').style.display='none';

	document.getElementById('bottomimage').style.display='none';

	document.getElementById('smallimage').style.display='none';

	document.getElementById('mediumimage').style.display='none';

	document.getElementById('largeimage').style.display='none';

	document.getElementById('extralargeimage').style.display='none';

}

function backimagejavascript() {

	document.getElementById('glanceimage').style.display='none';

	document.getElementById('frontimage').style.display='none';

	document.getElementById('backimage').style.display='block';

	document.getElementById('leftimage').style.display='none';

	document.getElementById('rightimage').style.display='none';

	document.getElementById('topimage').style.display='none';

	document.getElementById('bottomimage').style.display='none';

	document.getElementById('smallimage').style.display='none';

	document.getElementById('mediumimage').style.display='none';

	document.getElementById('largeimage').style.display='none';

	document.getElementById('extralargeimage').style.display='none';

}

function leftimagejavascript() {

	document.getElementById('glanceimage').style.display='none';

	document.getElementById('frontimage').style.display='none';

	document.getElementById('backimage').style.display='none';

	document.getElementById('leftimage').style.display='block';

	document.getElementById('rightimage').style.display='none';

	document.getElementById('topimage').style.display='none';

	document.getElementById('bottomimage').style.display='none';

	document.getElementById('smallimage').style.display='none';

	document.getElementById('mediumimage').style.display='none';

	document.getElementById('largeimage').style.display='none';

	document.getElementById('extralargeimage').style.display='none';

}

function rightimagejavascript() {

	document.getElementById('glanceimage').style.display='none';

	document.getElementById('frontimage').style.display='none';

	document.getElementById('backimage').style.display='none';

	document.getElementById('leftimage').style.display='none';

	document.getElementById('rightimage').style.display='block';

	document.getElementById('topimage').style.display='none';

	document.getElementById('bottomimage').style.display='none';

	document.getElementById('smallimage').style.display='none';

	document.getElementById('mediumimage').style.display='none';

	document.getElementById('largeimage').style.display='none';

	document.getElementById('extralargeimage').style.display='none';

}

function topimagejavascript() {

	document.getElementById('glanceimage').style.display='none';

	document.getElementById('frontimage').style.display='none';

	document.getElementById('backimage').style.display='none';

	document.getElementById('leftimage').style.display='none';

	document.getElementById('rightimage').style.display='none';

	document.getElementById('topimage').style.display='block';

	document.getElementById('bottomimage').style.display='none';

	document.getElementById('smallimage').style.display='none';

	document.getElementById('mediumimage').style.display='none';

	document.getElementById('largeimage').style.display='none';

	document.getElementById('extralargeimage').style.display='none';

}

function bottomimagejavascript() {

	document.getElementById('glanceimage').style.display='none';

	document.getElementById('frontimage').style.display='none';

	document.getElementById('backimage').style.display='none';

	document.getElementById('leftimage').style.display='none';

	document.getElementById('rightimage').style.display='none';

	document.getElementById('topimage').style.display='none';

	document.getElementById('bottomimage').style.display='block';

	document.getElementById('smallimage').style.display='none';

	document.getElementById('mediumimage').style.display='none';

	document.getElementById('largeimage').style.display='none';

	document.getElementById('extralargeimage').style.display='none';

}

function smallimagejavascript() {

	document.getElementById('glanceimage').style.display='none';

	document.getElementById('frontimage').style.display='none';

	document.getElementById('backimage').style.display='none';

	document.getElementById('leftimage').style.display='none';

	document.getElementById('rightimage').style.display='none';

	document.getElementById('topimage').style.display='none';

	document.getElementById('bottomimage').style.display='none';

	document.getElementById('smallimage').style.display='block';

	document.getElementById('mediumimage').style.display='none';

	document.getElementById('largeimage').style.display='none';

	document.getElementById('extralargeimage').style.display='none';

}

function mediumimagejavascript() {

	document.getElementById('glanceimage').style.display='none';

	document.getElementById('frontimage').style.display='none';

	document.getElementById('backimage').style.display='none';

	document.getElementById('leftimage').style.display='none';

	document.getElementById('rightimage').style.display='none';

	document.getElementById('topimage').style.display='none';

	document.getElementById('bottomimage').style.display='none';

	document.getElementById('smallimage').style.display='none';

	document.getElementById('mediumimage').style.display='block';

	document.getElementById('largeimage').style.display='none';

	document.getElementById('extralargeimage').style.display='none';

}

function largeimagejavascript() {

	document.getElementById('glanceimage').style.display='none';

	document.getElementById('frontimage').style.display='none';

	document.getElementById('backimage').style.display='none';

	document.getElementById('leftimage').style.display='none';

	document.getElementById('rightimage').style.display='none';

	document.getElementById('topimage').style.display='none';

	document.getElementById('bottomimage').style.display='none';

	document.getElementById('smallimage').style.display='none';

	document.getElementById('mediumimage').style.display='none';

	document.getElementById('largeimage').style.display='block';

	document.getElementById('extralargeimage').style.display='none';

}

function extralargeimagejavascript() {

	document.getElementById('glanceimage').style.display='none';

	document.getElementById('frontimage').style.display='none';

	document.getElementById('backimage').style.display='none';

	document.getElementById('leftimage').style.display='none';

	document.getElementById('rightimage').style.display='none';

	document.getElementById('topimage').style.display='none';

	document.getElementById('bottomimage').style.display='none';

	document.getElementById('smallimage').style.display='none';

	document.getElementById('mediumimage').style.display='none';

	document.getElementById('largeimage').style.display='none';

	document.getElementById('extralargeimage').style.display='block';

}

function smalltextjavascript() {

	document.getElementById("glancetext").style.color= "silver";

	document.getElementById("glancetext").style.cursor= "pointer";

	document.getElementById("fronttext").style.color= "silver";

	document.getElementById("fronttext").style.cursor= "pointer";

	document.getElementById("backtext").style.color= "silver";

	document.getElementById("backtext").style.cursor= "pointer";

	document.getElementById("lefttext").style.color= "silver";

	document.getElementById("lefttext").style.cursor= "pointer";

	document.getElementById("righttext").style.color= "silver";

	document.getElementById("righttext").style.cursor= "pointer";

	document.getElementById("toptext").style.color= "silver";

	document.getElementById("toptext").style.cursor= "pointer";

	document.getElementById("bottomtext").style.color= "silver";

	document.getElementById("bottomtext").style.cursor= "pointer";

	document.getElementById("smalltext").style.color = "rgb(255,215,0)";

	document.getElementById("smalltext").style.cursor= "text";

	document.getElementById("mediumtext").style.color= "silver";

	document.getElementById("mediumtext").style.cursor= "pointer";

	document.getElementById("largetext").style.color= "silver";

	document.getElementById("largetext").style.cursor= "pointer";

	document.getElementById("extralargetext").style.color= "silver";

	document.getElementById("extralargetext").style.cursor= "pointer";

}

function mediumtextjavascript() {

	document.getElementById("glancetext").style.color= "silver";

	document.getElementById("glancetext").style.cursor= "pointer";

	document.getElementById("fronttext").style.color= "silver";

	document.getElementById("fronttext").style.cursor= "pointer";

	document.getElementById("backtext").style.color= "silver";

	document.getElementById("backtext").style.cursor= "pointer";

	document.getElementById("lefttext").style.color= "silver";

	document.getElementById("lefttext").style.cursor= "pointer";

	document.getElementById("righttext").style.color= "silver";

	document.getElementById("righttext").style.cursor= "pointer";

	document.getElementById("toptext").style.color= "silver";

	document.getElementById("toptext").style.cursor= "pointer";

	document.getElementById("bottomtext").style.color= "silver";

	document.getElementById("bottomtext").style.cursor= "pointer";

	document.getElementById("smalltext").style.color= "silver";

	document.getElementById("smalltext").style.cursor= "pointer";

	document.getElementById("mediumtext").style.color = "rgb(255,215,0)";

	document.getElementById("mediumtext").style.cursor= "text";

	document.getElementById("largetext").style.color= "silver";

	document.getElementById("largetext").style.cursor= "pointer";

	document.getElementById("extralargetext").style.color= "silver";

	document.getElementById("extralargetext").style.cursor= "pointer";

}

function largetextjavascript() {

	document.getElementById("glancetext").style.color= "silver";

	document.getElementById("glancetext").style.cursor= "pointer";

	document.getElementById("fronttext").style.color= "silver";

	document.getElementById("fronttext").style.cursor= "pointer";

	document.getElementById("backtext").style.color= "silver";

	document.getElementById("backtext").style.cursor= "pointer";

	document.getElementById("lefttext").style.color= "silver";

	document.getElementById("lefttext").style.cursor= "pointer";

	document.getElementById("righttext").style.color= "silver";

	document.getElementById("righttext").style.cursor= "pointer";

	document.getElementById("toptext").style.color= "silver";

	document.getElementById("toptext").style.cursor= "pointer";

	document.getElementById("bottomtext").style.color= "silver";

	document.getElementById("bottomtext").style.cursor= "pointer";

	document.getElementById("smalltext").style.color= "silver";

	document.getElementById("smalltext").style.cursor= "pointer";

	document.getElementById("mediumtext").style.color= "silver";

	document.getElementById("mediumtext").style.cursor= "pointer";

	document.getElementById("largetext").style.color = "rgb(255,215,0)";

	document.getElementById("largetext").style.cursor= "text";

	document.getElementById("extralargetext").style.color= "silver";

	document.getElementById("extralargetext").style.cursor= "pointer";

}

function extralargetextjavascript() {

	document.getElementById("glancetext").style.color= "silver";

	document.getElementById("glancetext").style.cursor= "pointer";

	document.getElementById("fronttext").style.color= "silver";

	document.getElementById("fronttext").style.cursor= "pointer";

	document.getElementById("backtext").style.color= "silver";

	document.getElementById("backtext").style.cursor= "pointer";

	document.getElementById("lefttext").style.color= "silver";

	document.getElementById("lefttext").style.cursor= "pointer";

	document.getElementById("righttext").style.color= "silver";

	document.getElementById("righttext").style.cursor= "pointer";

	document.getElementById("toptext").style.color= "silver";

	document.getElementById("toptext").style.cursor= "pointer";

	document.getElementById("bottomtext").style.color= "silver";

	document.getElementById("bottomtext").style.cursor= "pointer";

	document.getElementById("smalltext").style.color= "silver";

	document.getElementById("smalltext").style.cursor= "pointer";

	document.getElementById("mediumtext").style.color= "silver";

	document.getElementById("mediumtext").style.cursor= "pointer";

	document.getElementById("largetext").style.color= "silver";

	document.getElementById("largetext").style.cursor= "pointer";

	document.getElementById("extralargetext").style.color = "rgb(255,215,0)";

	document.getElementById("extralargetext").style.cursor= "text";

}

function validateForm() {

	if (document.forms["form"]["quantity"].value=="") {

		alert ("Cannot submit because a quantity has not been specified.");

		return false;

	}

	if (document.forms["form"]["quantity"].value = > <?php echo $row['sizes']; ?>) {

		alert ("Cannot submit because quantity exceeds availability.");

		return false;

	}

	if (document.forms["form"]["size"].value=="") {

		alert ("Cannot submit because a size has not been selected.");

		return false;

	}

}

</SCRIPT>

<DIV>

<IMG alt="" class="logo" src="/logo.png">

<DIV class="customermenu"><?php include '../../../../rawcode/customermenu/customermenu'; ?></DIV>

<DIV class="mainmenu"><?php include '../../../../rawcode/mainmenu/products'; ?></DIV>

<DIV class="main">

	<?php $id = "1"; ?>

	<DIV class="path">> <A class="gold" href="/products">Products</A> > <A class="gold" href="/products/menswear">Menswear</A> > <A class="gold" href="/products/menswear/belts">Belts</A> > <?php echo "$id"; ?></DIV>

	<DIV class="imagearea">

		<DIV class="imageselector"><B>IMAGES:</B> | <SPAN class="glance" onclick="glanceimagejavascript()"><SPAN id="glancetext" onclick="glancetextjavascript()">GLANCE</SPAN></SPAN> | <SPAN class="front" onclick="frontimagejavascript()"><SPAN id="fronttext" onclick="fronttextjavascript()">FRONT</SPAN></SPAN> | <SPAN class="back" onclick="backimagejavascript()"><SPAN id="backtext" onclick="backtextjavascript()">BACK</SPAN></SPAN> | <SPAN class="left" onclick="leftimagejavascript()"><SPAN id="lefttext" onclick="lefttextjavascript()">LEFT</SPAN></SPAN> | <SPAN class="right" onclick="rightimagejavascript()"><SPAN id="righttext" onclick="righttextjavascript()">RIGHT</SPAN></SPAN> | <SPAN class="top" onclick="topimagejavascript()"><SPAN id="toptext" onclick="toptextjavascript()">TOP</SPAN></SPAN> | <SPAN class="bottom" onclick="bottomimagejavascript()"><SPAN id="bottomtext" onclick="bottomtextjavascript()">BOTTOM</SPAN></SPAN> |</DIV>

		<IMG alt="" class="glance" id="glanceimage" src="glance.png">

		<IMG alt="" class="front" id="frontimage" src="front.png">

		<IMG alt="" class="back" id="backimage" src="back.png">

		<IMG alt="" class="left" id="leftimage" src="left.png">

		<IMG alt="" class="right" id="rightimage" src="right.png">

		<IMG alt="" class="top" id="topimage" src="top.png">

		<IMG alt="" class="bottom" id="bottomimage" src="bottom.png">

		<IMG alt="" class="small" id="smallimage" src="small.png">

		<IMG alt="" class="medium" id="mediumimage" src="medium.png">

		<IMG alt="" class="large" id="largeimage" src="large.png">

		<IMG alt="" class="extralarge" id="extralargeimage" src="extralarge.png">

		<DIV class="dimensionsselector"><B>DIMENSIONS:</B> | <SPAN class="small" onclick="smallimagejavascript()"><SPAN id="smalltext" onclick="smalltextjavascript()">SMALL</SPAN></SPAN> | <SPAN class="medium" onclick="mediumimagejavascript()"><SPAN id="mediumtext" onclick="mediumtextjavascript()">MEDIUM</SPAN></SPAN> | <SPAN class="large" onclick="largeimagejavascript()"><SPAN id="largetext" onclick="largetextjavascript()">LARGE</SPAN></SPAN> | <SPAN class="extralarge" onclick="extralargeimagejavascript()"><SPAN id="extralargetext" onclick="extralargetextjavascript()">EXTRA LARGE</SPAN></SPAN> |</DIV>

	</DIV>

	<DIV class="productinformation">

		<B>Product ID:</B> <?php echo "$id"; ?>

		<BR>

		<BR>

		<B>Name:</B> <?php echo "$row[name]"; ?>

		<BR>

		<B>Brand:</B> <?php echo "$row[brand]"; ?>

		<BR>

		<B>Primary colour:</B> <?php echo "$row[primarycolour]"; ?>

		<BR>

		<B>Material:</B> <?php echo "$row[material]"; ?>

		<BR>

		Made in <?php echo "$row[madein]"; ?>

		<BR>

		<BR>

		<B>Price:</B> <? echo "$row[price]"; ?>

		<BR>

		<BR>

		<B>Size availability:</B>

		<BR>

		<DIV class="options">

			<DIV class="sizeavailability">

				<?php

					if ($row['sizes'] == 0) {goto sizem;} else {echo '<DIV class="sizesmall"><B>Small:</B> '.$row[sizes].'</DIV>';}

					sizem:

					if ($row['sizem'] == 0) {goto sizel;} else {echo '<DIV class="sizemedium"><B>Medium:</B> '.$row[sizem].'</DIV>';}

					sizel:

					if ($row['sizel'] == 0) {goto sizexl;} else {echo '<DIV class="sizelarge"><B>Large:</B> '.$row[sizel].'</DIV>';}

					sizexl:

					if ($row['sizexl'] == 0) {goto endsizes;} else {echo '<DIV class="sizeextralarge"><B>Extra large:</B> '.$row[sizexl].'</DIV>';}

					endsizes:

					mysql_query ($query);

					mysql_close($link);

				?>

			</DIV>

			<BR>

			<BR>

			<FORM action="../../../../cart/addtocart.html" method="post" name="form" onsubmit="return validateForm()"><DIV>Add <INPUT class="quantity" name="quantity" value="1"> <SELECT class="size" name="size"><OPTION></OPTION><OPTION>Small</OPTION><OPTION>Medium</OPTION><OPTION>Large</OPTION><OPTION>Extra large</OPTION></SELECT> to <INPUT class="cart" type="submit" value="CART"><INPUT name="id" type="hidden" value="<?php echo $id; ?>"></DIV></FORM>

		</DIV>

	</DIV>

</DIV>

<DIV class="information"><?php include '../../../../rawcode/information/information'; ?></DIV>

<DIV class="copyright"><?php include '../../../../rawcode/copyright/acopyright'; ?></DIV>

</DIV>

Share this post


Link to post
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.