This is the JavaScript Function that Jump to the relevant page
function bun(){
//var quantity=parseInt(fid);
window.location = 'ubun.php'
}
function pat(){
//var quantity=parseInt(fid);
window.location = 'upatties.php'
}
function pats(){
//var quantity=parseInt(fid);
window.location = 'utoppings.php'
}
function sau(){
//var quantity=parseInt(fid);
window.location = 'usauces.php'
}
</script>
This is the if else function code that are problematic
<input type="button" value="Bun Selection"
<?php
if($fid==4 || $fid==8 || $fid==11 ||$fid==21 ||$fid==5 ||$fid==6||$fid==7||$fid==9||$fid==10||$fid==41||$fid==40||$fid==12||$fid==13||$fid==14
||$fid==15||$fid==16||$fid==17||$fid==18||$fid==19||$fid==20||$fid==22
||$fid==23||$fid==24||$fid==25||$fid==26||$fid==27||$fid==28||$fid==29
||$fid==30)
{
echo ' disabled=disabled ';
}
else
{
echo ' onclick=bun() ';
}
?>
/>
<input type="button" value="Patties Selection"
<?php
if($fid==8 || $fid==11 ||$fid==21
||$fid==9||$fid==10||$fid==41||$fid==40||$fid==12||$fid==13||$fid==14
||$fid==15||$fid==16||$fid==17||$fid==18||$fid==19||$fid==20||$fid==22
||$fid==23||$fid==24||$fid==25||$fid==26||$fid==27||$fid==28||$fid==29
||$fid==30)
{
echo ' disabled=disabled ';
}
else
{
echo ' onclick=pat() ';
}
?>
/>
<input type="button" value="Toppings Selection"
<?php if($fid==11 ||$fid==21
||$fid==40||$fid==12||$fid==13||$fid==14
||$fid==15||$fid==16||$fid==17||$fid==18||$fid==19||$fid==20||$fid==22
||$fid==23||$fid==24||$fid==25||$fid==26||$fid==27||$fid==28||$fid==29
||$fid==30)
{
echo ' disabled=disabled ';
}
else
{
echo 'onclick=pats()';
}
?>
/>
<input type="button" value="Sauces Selection"
<?php if($fid==21 || $fid==22
||$fid==23||$fid==24||$fid==25||$fid==26||$fid==27||$fid==28||$fid==29
||$fid==30||$fid==40)
{
echo ' disabled=disabled ';
}
else
{
echo ' onclick=sau() ';
}
?>
/>
The above code run smoothly when i first go to the shopping cart bun, then patties then toppings and finally sauces. the button will disable one at a time for example if i pick bun then the bun selection will be disable, it is the same with patties, toppings and sauces, the button will disable after the selected product are chosen inorder.
If it is in random then my main problem is that when i pick sauce first then the other three button (bun, patties and toppings) will also disappear. It is the same with if i choose toppings first the other two button (bun and patties) will disappear, but the sauce button can be click.
I was trying to pick the product at random choices.Are there any solution to my problem?
fid is the id for product id...... for bun id (4,5,6,7) for patties id (8,9,10,41) for toppings id (11,12,13,14,15,16,17,18,19,20) for sauces id (20,21,22,23,24,25,26,27,28,29,30,40)
Try to use in_array function in php. it make your code easier to read and clean
<?php
$fid =7; // this is only to show
$ids = array(1,2,3,4,5,6,8,); // this is the array item to be compare
if (in_array($fid, $ids)) // check if $fid is in list ($ids)
{
echo ' disabled=disabled '; // this will output if $fid is in the array list
}else{
echo ' onclick=bun() '; // this will output if $fid is not in the array list
}
?>
this will ouput "onclick=bun()" because 7 is not in the list. Hope this will help.