Author Topic: JavaScript error on editaddresscheckoutBT page [SOLVED partially]  (Read 2129 times)

xenol

  • Beginner
  • *
  • Posts: 2
Hi to all. Sorry for bad english.
I have Virtuemart 2.6.6 and joomla  2.5.24
url page: http://www.phenixinstitut.com/virtuemart/user/editaddresscheckoutBT
problem: after click on button "Inscrivez-vous et commandez" (register and buy) I have javascript error - Cannot set property 'value' of undefined.
It is on javascript line: f.task.value = t; //this is a method to set the task of the form on the fTask.
I have no override template for this page, I have native template.
I know why this error occur: we have tag </form> that early closed.
I find the file, that consist this error: \my_site\components\com_virtuemart\views\user\tmpl\edit_address.php and something closed tag </form> earlier.

And now amazing: look at 189 line of this file: "</form>" - without quotes this tag always disappears. If i change this line, for example, to "1</form>2", save it, and reload page, I have on page source "12" this line, no tag </form> closed - it is disappears
Code: [Select]
<?php
/**
 *
 * Enter address data for the cart, when anonymous users checkout
 *
 * @package    VirtueMart
 * @subpackage User
 * @author Oscar van Eijk, Max Milbers
 * @link http://www.virtuemart.net
 * @copyright Copyright (c) 2004 - 2010 VirtueMart Team. All rights reserved.
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
 * VirtueMart is free software. This version may have been modified pursuant
 * to the GNU General Public License, and as distributed it includes or
 * is derivative of works licensed under the GNU General Public License or
 * other free or open source software licenses.
 * @version $Id: edit_address.php 6406 2012-09-08 09:46:55Z Milbo $
 */
// Check to ensure this file is included in Joomla!
defined ('_JEXEC') or die('Restricted access');
// vmdebug('user edit address',$this->userFields['fields']);
// Implement Joomla's form validation
JHTML::('behavior.formvalidation');
JHTML::stylesheet ('vmpanels.css'JURI::root () . 'components/com_virtuemart/assets/css/');

if (
$this->fTask === 'savecartuser') {
$rtask 'registercartuser';
$url 0;
}
else {
$rtask 'registercheckoutuser';
$url JRoute::_('index.php?option=com_virtuemart&view=cart&task=checkout'0$this->useSSL);
}
?>

<h1><?php echo $this->page_title ?></h1>
<?php
echo shopFunctionsF::getLoginForm (TRUEFALSE$url);
?>

<script language="javascript">
function myValidator(f, t) {
f.task.value = t; //this is a method to set the task of the form on the fTask.
if (document.formvalidator.isValid(f)) {
if (jQuery('#recaptcha_wrapper').is(':hidden') && ((t == 'registercartuser') || (t == 'registercheckoutuser'))) {
jQuery('#recaptcha_wrapper').show();
} else {
f.submit();
return true;
}
} else {
if (jQuery('#recaptcha_wrapper').is(':hidden') && ((t == 'registercartuser') || (t == 'registercheckoutuser'))) {
jQuery('#recaptcha_wrapper').show();
}
var msg = '<?php echo addslashes (vmText::('COM_VIRTUEMART_USER_FORM_MISSING_REQUIRED_JS')); ?>';
alert(msg + ' ');
}
return false;
}

function callValidatorForRegister(f) {

var elem = jQuery('#username_field');
elem.attr('class', "required");

var elem = jQuery('#name_field');
elem.attr('class', "required");

var elem = jQuery('#password_field');
elem.attr('class', "required");

var elem = jQuery('#password2_field');
elem.attr('class', "required");

var elem = jQuery('#userForm');

return myValidator(f, '<?php echo $rtask ?>');

}
</script>

<fieldset>
<h2><?php
if ($this->address_type == 'BT') {
echo JText::('COM_VIRTUEMART_USER_FORM_EDIT_BILLTO_LBL');
}
else {
echo JText::('COM_VIRTUEMART_USER_FORM_ADD_SHIPTO_LBL');
}
?>

</h2>

<form method="post" id="userForm" name="userForm" class="form-validate" action="<?php echo JRoute::_('index.php?option=com_virtuemart&view=user',$this->useXHTML,$this->useSSL?>" >
<!--<form method="post" id="userForm" name="userForm" action="<?php echo JRoute::('index.php'); ?>" class="form-validate">-->
<div class="control-buttons">
<?php
if (strpos ($this->fTask'cart') || strpos ($this->fTask'checkout')) {
$rview 'cart';
}
else {
$rview 'user';
}
// echo 'rview = '.$rview;

if (strpos ($this->fTask'checkout') || $this->address_type == 'ST') {
$buttonclass 'default';
}
else {
$buttonclass 'button vm-button-correct';
}


if (VmConfig::get ('oncheckout_show_register'1) && $this->userId == && !VmConfig::get ('oncheckout_only_registered'0) && $this->address_type == 'BT' and $rview == 'cart') {
echo JText::sprintf ('COM_VIRTUEMART_ONCHECKOUT_DEFAULT_TEXT_REGISTER'JText::('COM_VIRTUEMART_REGISTER_AND_CHECKOUT'), JText::('COM_VIRTUEMART_CHECKOUT_AS_GUEST'));
}
else {
//echo JText::_('COM_VIRTUEMART_REGISTER_ACCOUNT');
}
if (VmConfig::get ('oncheckout_show_register'1) && $this->userId == && $this->address_type == 'BT' and $rview == 'cart') {
?>


<button class="<?php echo $buttonclass ?>" type="submit" onclick="javascript:return callValidatorForRegister(userForm);"
        title="<?php echo JText::('COM_VIRTUEMART_REGISTER_AND_CHECKOUT'); ?>"><?php echo JText::('COM_VIRTUEMART_REGISTER_AND_CHECKOUT'); ?></button>
<?php if (!VmConfig::get ('oncheckout_only_registered'0)) { ?>
<button class="<?php echo $buttonclass ?>" title="<?php echo JText::('COM_VIRTUEMART_CHECKOUT_AS_GUEST'); ?>" type="submit"
        onclick="javascript:return myValidator(userForm, '<?php echo $this->fTask?>');"><?php echo JText::('COM_VIRTUEMART_CHECKOUT_AS_GUEST'); ?></button>
<?php ?>
<button class="default" type="reset"
        onclick="window.location.href='<?php echo JRoute::('index.php?option=com_virtuemart&view=' $rview); ?>'"><?php echo JText::('COM_VIRTUEMART_CANCEL'); ?></button>


<?php
}
else {
?>


<button class="<?php echo $buttonclass ?>" type="submit"
        onclick="javascript:return myValidator(userForm, '<?php echo $this->fTask?>');"><?php echo JText::('COM_VIRTUEMART_SAVE'); ?></button>
<button class="default" type="reset"
        onclick="window.location.href='<?php echo JRoute::('index.php?option=com_virtuemart&view=' $rview); ?>'"><?php echo JText::('COM_VIRTUEMART_CANCEL'); ?></button>

<?php ?>
</div>

<?php
// captcha addition
if(VmConfig::get ('reg_captcha')){
JHTML::_('behavior.framework');
JPluginHelper::importPlugin('captcha');
$captcha_visible vRequest::getVar('captcha');
$dispatcher JDispatcher::getInstance(); $dispatcher->trigger('onInit','dynamic_recaptcha_1');
$hide_captcha = (VmConfig::get ('oncheckout_only_registered') or $captcha_visible) ? '' 'style="display: none;"';
?>

<fieldset id="recaptcha_wrapper" <?php echo $hide_captcha ?>>
<?php if(!VmConfig::get ('oncheckout_only_registered')) { ?>
<span class="userfields_info"><?php echo vmText::('COM_VIRTUEMART_USER_FORM_CAPTCHA'); ?></span>
<?php ?>
<div id="dynamic_recaptcha_1"></div>
</fieldset>
<?php 
}
// end of captcha addition 

if (!class_exists ('VirtueMartCart')) {
require(JPATH_VM_SITE DS 'helpers' DS 'cart.php');
}

if (count ($this->userFields['functions']) > 0) {
echo '<script language="javascript">' "\n";
echo join ("\n"$this->userFields['functions']);
echo '</script>' "\n";
}
echo $this->loadTemplate ('userfields');

?>

</fieldset>
<?php // }
if ($this->userDetails->JUser->get ('id')) {
echo $this->loadTemplate ('addshipto');
?>

<input type="hidden" name="option" value="com_virtuemart"/>
<input type="hidden" name="view" value="user"/>
<input type="hidden" name="controller" value="user"/>
<input type="hidden" name="task" value="<?php echo $this->fTask?>"/>
<input type="hidden" name="layout" value="<?php echo $this->getLayout (); ?>"/>
<input type="hidden" name="address_type" value="<?php echo $this->address_type?>"/>
<?php if (!empty($this->virtuemart_userinfo_id)) {
echo '<input type="hidden" name="shipto_virtuemart_userinfo_id" value="' . (int)$this->virtuemart_userinfo_id '" />';
}
echo 
JHTML::('form.token');
?>

</form>

xenol

  • Beginner
  • *
  • Posts: 2
Re: JavaScript error on editaddresscheckoutBT page
« Reply #1 on: July 30, 2014, 18:44:32 pm »
It is bug when show delimiter field in file edit_address_userfields.php That's all right when I disable delimiter.
Displaying delimiter also breaks some pages website design

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 10638
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.8.8
Re: JavaScript error on editaddresscheckoutBT page
« Reply #2 on: July 30, 2014, 19:06:08 pm »
Well found - will help some people no doubt - thanks
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation