...

View Full Version : Javascript to call warning message if box not ticked



bensd
07-08-2012, 09:25 AM
I am working on an ecommerce site using opencart.

The original checkout page flags up a warning if you don't tick the terms and conditions box.

Original checkout page (terms & conditions section):

<?php if ($error_warning) { ?>
<div class="warning"><?php echo $error_warning; ?></div>
<?php } ?>
<?php if ($payment_methods) { ?>
<p><?php echo $text_payment_method; ?></p>
<table class="radio">
<?php foreach ($payment_methods as $payment_method) { ?>
<tr class="highlight">
<td><?php if ($payment_method['code'] == $code || !$code) { ?>
<?php $code = $payment_method['code']; ?>
<input type="radio" name="payment_method" value="<?php echo $payment_method['code']; ?>" id="<?php echo $payment_method['code']; ?>" checked="checked" />
<?php } else { ?>
<input type="radio" name="payment_method" value="<?php echo $payment_method['code']; ?>" id="<?php echo $payment_method['code']; ?>" />
<?php } ?></td>
<td><label for="<?php echo $payment_method['code']; ?>"><?php echo $payment_method['title']; ?></label></td>
</tr>
<?php } ?>
</table>
<br />
<?php } ?>
<b><?php echo $text_comments; ?></b>
<textarea name="comment" rows="8" style="width: 98%;"><?php echo $comment; ?></textarea>
<br />
<br />
<?php if ($text_agree) { ?>
<div class="buttons">
<div class="right"><?php echo $text_agree; ?>
<?php if ($agree) { ?>
<input type="checkbox" name="agree" value="1" checked="checked" />
<?php } else { ?>
<input type="checkbox" name="agree" value="1" />
<?php } ?>
<input type="button" value="<?php echo $button_continue; ?>" id="button-payment-method" class="button" />
</div>
</div>
<?php } else { ?>
<div class="buttons">
<div class="right">
<input type="button" value="<?php echo $button_continue; ?>" id="button-payment-method" class="button" />
</div>
</div>
<?php } ?>
<script type="text/javascript"><!--
$('.colorbox').colorbox({
width: 560,
height: 560
});
//--></script>

I recently bought a different checkout module (ubercart) which compacts the checkout process.

The deafult setting of ubercart only shows the payment method when you click the terms and conditions. I didn't like this I have set it so the payment method is always shown however, I now need to call an error if the terms and conditions box isn't ticked.

Ubercart checkout page (terms & conditions section):

<!-- Agree -->
<?php if ($text_agree) { ?>
<div class="buttons agree">
<div class="right" style="width:100%"><?php echo $text_agree; ?>
<?php if ($agree) { ?>
<input type="checkbox" name="agree" value="1" checked="checked" />
<?php } else { ?>
<input type="checkbox" name="agree" value="1" />
<?php } ?>
</div>
</div>
<?php } ?>
<!-- Agree -->


<!-- Payment -->
<div class="content" id="payment_div"<?php echo $payment; ?></div>
<!-- Payment -->

If anyone could help it would be much appreciated.

Sing
07-09-2012, 03:56 AM
This is a PHP / server side issue, your original code didn't use javascript to alert anything

bensd
07-09-2012, 06:57 AM
This is a PHP / server side issue, your original code didn't use javascript to alert anything
Thanks for your reply.

I should have posted the entire original checkout page. It is too long to post so I have attached it.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum