View Full Version : Activate javascript from another javascript snipnet

01-19-2012, 08:14 PM
Hi Guys I am trying to modify the functionality of my page. I want to be able to activate this piece of code using another javascript function.

This is the code I want to activate:

<script type="text/javascript"><!--
$('#button-cart').bind('click', function() {
url: 'index.php?route=checkout/cart/update',
type: 'post',
data: $('.product-info input[type=\'text\'], .product-info input[type=\'hidden\'], .product-info input[type=\'radio\']:checked, .product-info input[type=\'checkbox\']:checked, .product-info select, .product-info textarea, .date_data input[type=\'text\']'),
dataType: 'json',
success: function(json) {
$('.success, .warning, .attention, information, .error').remove();

if (json['error']) {
if (json['error']['warning']) {
$('#notification').html('<div class="warning" style="display: none;">' + json['error']['warning'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');


for (i in json['error']) {
$('#option-' + i).after('<span class="error">' + json['error'][i] + '</span>');

if (json['success']) {
$('#notification').html('<div class="success" style="display: none;">' + json['success'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');



$('html, body').animate({ scrollTop: 0 }, 'slow');

And this is how I want the format of the function to be:

function testsession() {
if there is a session called 'hiredate' {
activate the script above
else {
var el = document.getElementById("product_data");

I just dont know how to write this in javascript :confused:

Could you help me if possible please :)

01-20-2012, 07:01 AM
What do you mean by "activate"? A script is "active" by default as soon as it is loaded. Do you mean you want to EXECUTE what is inside the .bind(function()) without actually clicking anywhere?

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum