hello i have a list of posts and i use javascript to download a post as pdf
but i have a problem because the download button works just on the first post and not in the others and when i inspect the button in the browser i can see the description below but the button not working
this is a part of my code if some one could help :
ps: the download button is : Imprimer l'offre
<li style=" border: 1px solid black; padding: 20px; margin-bottom: 30px;" <?php job_listing_class(); ?> data-longitude="<?php echo esc_attr($post->geolocation_long); ?>" data-latitude="<?php echo esc_attr($post->geolocation_lat); ?>">
<!-- <a href="<?php the_job_permalink(); ?>">
-->
<!-- <?php the_company_logo(); ?> -->
<div class="work-section">
<h3><?php wpjm_the_job_title(); ?> <?php echo "Job ID: " . $post->ID ?> </h3>
<!-- <div class="company">
<?php the_company_name('<strong>', '</strong> '); ?>
<?php the_company_tagline('<span class="tagline">', '</span>'); ?>
</div> -->
</div>
<!-- <div class="location">
<?php the_job_location(false); ?>
</div> -->
<div id="tblCustomers">
<div id="collapseExample<?php echo $post->ID ?>" class=" collapse job_description">
<?php wpjm_the_job_description(); ?>
</div>
<div id="print-btn"></div>
</div>
<center>
<div class="vc_btn3-container red-btn vc_btn3-inline" style="margin-top: 20px">
<button id="pdfview" data-target="<?php echo $post->ID ?>" style="text-align: center;">
Imprimer l’offre
</button>
<div id="pdfdiv" style="display: none;">
<?php wpjm_the_job_description(); ?>
</div>
<div id="editor"></div>
<script type="text/javascript">
var $ = jQuery.noConflict();
$(window).on('load', function() {
var doc = new jsPDF();
var specialElementHandlers = {
'#editor': function(element, renderer) {
return true;
}
};
$('#pdfview').click(function() {
doc.fromHTML($('#pdfdiv').html(), 15, 15, {
'width': 700,
'elementHandlers': specialElementHandlers
});
doc.save('file.pdf');
});
});
</script>
</div>
Related
I have below code for fetching data using Jquery/ajax from mysql database.
I have load more button in it which is working without any issue.
But i want to add Show less button also how can i add?
( Suppose displaying 12 records on each Load more click. When i click on Load more it will be 24 and it should show Show Less button also.
When a user will click on Show Less remained will be 12 and Show Less button should be hidden. and if user clicked show More button several time and show less button will work accordingly it will be hidden only when only left records are equal to 12.)
Can somebody help to add Show Less button within my code or a better code.
PHP
<div id="alldata">
<?php
$serial = 1;
$query = mysqli_query($dba, "SELECT * FROM mybooklibrary WHERE status = 1 limit 12");
while ($get_info = mysqli_fetch_array($query)) {
$eid = $get_info['id'];
$ename = $get_info['ename'];
$enames = $get_info['enames'];
$aname = $get_info['aname'];
$filename = $get_info['filename'];
//remove brackets or whatever from name of current product
$aReplace = array('(', ')', '.');
$ename_replaces = str_replace($aReplace , '', $ename);
//////////////////////////////////////////////////////////
$url_ename6 = url_making($ename_replaces);
?>
<div class="moreData" id="<?php echo $eid;?>">
<div class="sidebar">
<div class="widget widget-shop">
<div class="product">
<div class="product-image" style="width: 112px;">
<a href="author/<?php echo $url_ename6; ?>">
<img style="box-shadow: 3px 3px 3px #ccc; border-radius: 3%;" alt="" src="<?php echo $filename; ?>">
</a>
<!--<span class="product-new">NEW</span>-->
</div>
<div class="product-description">
<!--<div class="product-category">Man - <?php echo $art_id; ?></div>-->
<div class="product-titlex">
<a href="bookDetails/<?php echo $url_ename6; ?>" style="font-weight: bold; text-shadow: 3px 3px 3px #ccc;">
<?php echo $ename; ?>
</a>
<div style="width: 200%;">
<a href="bookDetails/<?php echo $url_ename6; ?>" style="color: gray;" style="">
<?php echo $enames; ?>
</a>
</div>
<hr style="min-width: 500%;">
<div>
<a href="bookDetails/<?php echo $url_ename6; ?>" class="ur1" style="font-weight: bold; float: right;">
<?php echo $aname; ?></a>
</div>
</div>
</div><hr style="border: 1px solid black; min-width: 300%;">
</div>
<!-- end: Sidebar-->
</div>
</div>
</div>
<?php $serial++; } ?>
</div>
<div id="load<?php echo $eid; ?>">
<a class="load btn btn-block" id="<?php echo $eid; ?>" >Load more</a>
</div>
get_moredata.php
<div id="alldata">
<?php
include ("includeme/db.php");
if(isset($_POST['lastid'])) {
$lastid = mysql_real_escape_string($_POST['lastid']);
$serial = 1;
$query = mysqli_query($dba, "SELECT * FROM mybooklibrary WHERE id > '".$lastid."' limit 12");
while ($get_info = mysqli_fetch_array($query)) {
$eid = $get_info['id'];
$ename = $get_info['ename'];
$enames = $get_info['enames'];
$aname = $get_info['aname'];
$filename = $get_info['filename'];
//remove brackets or whatever from name of current product
$aReplace = array('(', ')', '.');
$ename_replaces = str_replace($aReplace , '', $ename);
//////////////////////////////////////////////////////////
$url_ename6 = url_making($ename_replaces);
?>
<div class="moreData" id="<?php echo $eid;?>">
<div class="sidebar">
<div class="widget widget-shop">
<div class="product">
<div class="product-image" style="width: 112px;">
<a href="author/<?php echo $url_ename6; ?>">
<img style="box-shadow: 3px 3px 3px #ccc; border-radius: 3%;" alt="" src="<?php echo $filename; ?>">
</a>
</div>
<div class="product-description">
<div class="product-titlex">
<a href="bookDetails/<?php echo $url_ename6; ?>" style="font-weight: bold; text-shadow: 3px 3px 3px #ccc;">
<?php echo $ename; ?>
</a>
<div style="width: 200%;">
<a href="bookDetails/<?php echo $url_ename6; ?>" style="color: gray;" style="">
<?php echo $enames; ?>
</a>
</div>
<hr style="min-width: 500%;">
<div>
<a href="bookDetails/<?php echo $url_ename6; ?>" class="ur1" style="font-weight: bold; float: right;">
<?php echo $aname; ?></a>
</div>
</div>
</div><hr style="border: 1px solid black; min-width: 300%;">
</div>
</div>
</div>
</div>
<?php $serial++; } ?>
<?php } ?>
<div id="load<?php echo $eid; ?>" class="sidebar">
<hr>
<a class="load btn btn-block" id="<?php echo $eid; ?>" >Load More</a>
</div>
</div>
JQuery / Ajax
$(document).ready(function(){
$(document).on("click",".load",function(){
//var ids= $('.moreData:last').attr("id");
var ids= $(this).attr("id");
//$(".load").html('<img src="ajax-loader.gif"/>');
$.ajax({
type: 'POST',
url: 'get_moredata.php',
cache:false,
data: {'lastid':ids},
success: function(response){
//appending the result get_moredata page result with div id alldata
$('#alldata').append(response);
//remove old load more button
$('#load'+ids).remove();
if(!response) {
$('.moreData').text('No more record to load');
}
}
});
});
});
Well solved it as below:
What i did is i have made two scripts One for Load More Records and one for Load Less Records, but the get_moredata.php is the same.
And in get_moredata.php i have made 2 queries as follows:
if(isset($_POST['lastids'])) { //this id is for View Less
$lastid_less = mysql_real_escape_string($_POST['lastids']); //this id is for View Less
$query = mysqli_query($dba, "SELECT * FROM mybooklibrary WHERE id <= '".$lastid_less."'-12");
}else if(isset($_POST['lastid'])) { //this id is for View More
$lastid_more = mysql_real_escape_string($_POST['lastid']); //this id is for View More
$query = mysqli_query($dba, "SELECT * FROM mybooklibrary WHERE id > '".$lastid_more."' limit 12");
}
So it run the scripts as of the button clicked.
PHP
<div id="alldata">
<?php
$serial = 1;
$query = mysqli_query($dba, "SELECT * FROM mybooklibrary WHERE status = 1 limit 12");
while ($get_info = mysqli_fetch_array($query)) {
$eid = $get_info['id'];
$ename = $get_info['ename'];
$enames = $get_info['enames'];
$aname = $get_info['aname'];
$filename = $get_info['filename'];
//remove brackets or whatever from name of current product
$aReplace = array('(', ')', '.');
$ename_replaces = str_replace($aReplace , '', $ename);
//////////////////////////////////////////////////////////
$url_ename6 = url_making($ename_replaces);
?>
<div class="moreData" id="<?php echo $eid;?>">
<div class="sidebar">
<div class="widget widget-shop">
<div class="product">
<div class="product-image" style="width: 112px;">
<a href="author/<?php echo $url_ename6; ?>">
<img style="box-shadow: 3px 3px 3px #ccc; border-radius: 3%;" alt="" src="<?php echo $filename; ?>">
</a>
<!--<span class="product-new">NEW</span>-->
</div>
<div class="product-description">
<!--<div class="product-category">Man - <?php echo $art_id; ?></div>-->
<div class="product-titlex">
<a href="bookDetails/<?php echo $url_ename6; ?>" style="font-weight: bold; text-shadow: 3px 3px 3px #ccc;">
<?php echo $ename; ?>
</a>
<div style="width: 200%;">
<a href="bookDetails/<?php echo $url_ename6; ?>" style="color: gray;" style="">
<?php echo $enames; ?>
</a>
</div>
<hr style="min-width: 500%;">
<div>
<a href="bookDetails/<?php echo $url_ename6; ?>" class="ur1" style="font-weight: bold; float: right;">
<?php echo $aname; ?></a>
</div>
</div>
</div><hr style="border: 1px solid black; min-width: 300%;">
</div>
<!-- end: Sidebar-->
</div>
</div>
</div>
<?php $serial++; } ?>
</div>
<div id="load<?php echo $eid; ?>">
<a class="load btn btn-block" id="<?php echo $eid; ?>" >Load more</a>
</div>
get_moredata.php
<div class="alldata">
<?php
include ("inc/db.php");
include ("inc/functions.php");
if(isset($_POST['lastids'])) {
$lastid_less = mysql_real_escape_string($_POST['lastids']); //this id is for View Less
$query = mysqli_query($dba, "SELECT * FROM mybooklibrary WHERE id <= '".$lastid_less."'-12");
}else if(isset($_POST['lastid'])) {
$lastid_more = mysql_real_escape_string($_POST['lastid']); //this id is for View More
$query = mysqli_query($dba, "SELECT * FROM mybooklibrary WHERE id > '".$lastid_more."' limit 12");
}
while ($get_info = mysqli_fetch_array($query)) {
$eid = $get_info['id'];
$ename = $get_info['ename'];
$enames = $get_info['enames'];
$aname = $get_info['aname'];
//remove brackets or whatever from name of current product
$aReplace = array('(', ')', '.');
$ename_replaces = str_replace($aReplace , '', $ename);
//////////////////////////////////////////////////////////
$url_ename6 = url_making($ename_replaces);
?>
<div class="moreData" id="<?php echo $eid;?>">
<div class="sidebar">
<div class="widget widget-shop">
<div class="product">
<div class="product-image" style="width: 112px;">
<a href="author/<?php echo $url_ename6; ?>">
<?php
$exts4 = array('png','jpg','jpeg','gif');
foreach (array_unique($exts4) as $ext4) {
if (file_exists("images/titles/".$get_info['id'].".".$ext4)) {
$path4 = "images/titles/".$get_info['id'].".".$ext4;
?>
<img style="box-shadow: 3px 3px 3px #ccc; border-radius: 3%;" alt="" src="<?php echo $path4; ?>">
<?php }} ?>
</a>
</div>
<div class="product-description">
<div class="product-titlex">
<a href="bookDetails/<?php echo $url_ename6; ?>" style="font-weight: bold; text-shadow: 3px 3px 3px #ccc;">
<?php echo $ename; ?>
</a>
<div style="width: 200%;">
<a href="bookDetails/<?php echo $url_ename6; ?>" style="color: gray;" style="">
<?php echo $enames; ?>
</a>
</div>
<hr style="min-width: 500%;">
<div>
<a href="bookDetails/<?php echo $url_ename6; ?>" class="ur1" style="font-weight: bold; float: right;">
<?php echo $aname; ?></a>
</div>
</div>
</div><hr style="border: 1px solid black; min-width: 300%;">
</div>
<!-- end: Sidebar-->
</div>
</div>
</div>
<?php } ?>
<?php
if (isset($lastid_less)) {
//count if clicked on lastid_less
$queryCount = mysqli_query($dba, "SELECT * FROM mybooklibrary WHERE id <= '$lastid_less'");
echo $get_Count = mysqli_num_rows($queryCount)-12;
}else{
//count if clicked on lastid_more
$queryCount = mysqli_query($dba, "SELECT * FROM mybooklibrary WHERE id <= '$lastid_more'");
echo $get_Count = mysqli_num_rows($queryCount)+12;
}
if ($get_Count <= 12) {
?>
<!-- show this button only if books are shown are less than equal to 12 -->
<!-- because my default is 12 -->
<div id="load<?php echo $eid; ?>" class="sidebar">
<hr>
<a class="load btn btn-block" id="<?php echo $eid; ?>" >View More</a>
</div>
<?php }else{ ?>
<!-- show both buttons if books are shown greater than 12 -->
<div id="load<?php echo $eid; ?>" class="sidebar">
<hr>
<a class="load btn btn-block" id="<?php echo $eid; ?>" >View More</a>
</div>
<div id="loads<?php echo $eid; ?>" class="sidebar">
<hr>
<a class="loads btn btn-block" id="<?php echo $eid; ?>" >View Less</a>
</div>
<?php } ?>
</div>
JQuery / Ajax for Load More Records
<script>
//this query is for Load More Records
$(document).ready(function(){
$(document).on("click",".load",function(){
var ids= $(this).attr("id");
$.ajax({
type: 'POST',
url: 'get_moredata.php',
cache:false,
data: {'lastid':ids},
success: function(response){
//appending the result get_moredata page result with div id alldata
$('#alldata').append(response);
//remove old load more button
$('#load'+ids).remove();
if(!response) {
$('.moreData').text('No more record to load');
}
}
});
});
});
</script>
JQuery / Ajax for Load Less Records
<script>
//this query is for Load Less Records
$(document).ready(function(){
$(document).on("click",".loads",function(){
var ids= $(this).attr("id");
$.ajax({
type: 'POST',
url: 'get_moredata.php',
cache:false,
data: {'lastids':ids},
success: function(response){
//appending the result get_moredata page result with div id alldata
$('#alldata').append(response);
//remove old load more button
$('#loads'+ids).remove();
if(!response) {
$('.moreData').text('No more record to load');
}
}
});
});
});
</script>
I use the rethink theme in wordpress, and use the wp-paginate plugin
in arcive.php, category.php and index.php pagination is fine
but why in page.php not running?
and I created my own template showing all the posts
posting.php
<?php
/*
Template Name: posting
*/
get_header();
?>
<div class="full-content">
<div class="grid_17 alpha">
<div class="content_bar">
<div class="feature_content">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php
$count_posts = wp_count_posts();
$published_posts = $count_posts->publish;
$myposts = get_posts(array('posts_per_page'=>3)); ;
foreach($myposts as $post) :
setup_postdata($post);
?>
<div id="post-<?php the_ID(); ?>" <?php post_class('product'); ?>>
<div class="post-info">
<h1 class="product_title">
<a href= "<?php the_permalink(); ?>" rel="bookmark" title="<?php echo sprintf(__("Permanent link to %s", 'rethink'), get_the_title(get_the_ID())); ?>">
<?php the_title(); ?>
</a>
</h1>
<div class="detail">
<ul class="post_meta">
<li class="admin"><?php printf(__("Posted by %s", 'rethink'), get_the_author_link()); ?></li>
<li class="date"><?php printf(__('Posted on %s', 'rethink'), get_the_time('F j, Y')); ?></li>
<li class="category"><?php the_category(','); ?></li>
<li class="commentt"><?php comments_popup_link(__('No Comments.', 'rethink'), __('1 Comment.', 'rethink'), __('% Comments.', 'rethink')); ?></li>
</ul>
</div>
</div>
<div class="post_thumbnail_wrapper">
<?php if (has_post_thumbnail()) { ?>
<a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail('post_thumbnail', array('class' => 'postimg')); ?>
</a>
<?php
} else {
echo rethink_main_image();
}
?>
</div>
<div class="product_content"><?php the_excerpt(); ?><div class="buttons"><a class="btn-2" href="<?php the_permalink() ?>"><span><?php _e('Read Review', 'rethink') ?></span></a></div>
</div>
</div>
<?php endforeach;
if(function_exists('wp_paginate')){
wp_paginate(); }
wp_reset_postdata(); ?>
<div class="clear"></div>
<?php endwhile;
else:
?>
<div class="product">
<p>
<?php _e('Sorry, no posts matched your criteria.', 'rethink'); ?>
</p>
</div>
<?php endif; ?>
</div>
</div>
</div>
<div class="grid_7 omega">
<!--Start Sidebar-->
<?php get_sidebar(); ?>
<!--End Sidebar-->
</div>
</div>
<?php get_footer(); ?>
how i want to display the pagination of my coding ????
sorry if the line of code is not neat I still newbie
Update this Code:
if(function_exists('wp_paginate')){
wp_paginate();
}
to this code:
if(function_exists('wp_paginate')){
wp_paginate(array('page' => 'page'));
}
I'm using advanced custom fields to repeat divs. There is a unique ID injected into the wrapper div for a click function that reveals content (i can't use a class because it triggers all the divs at once).
How do I target this ID in my javascript function dynamically? Here is my code;
<?php if( have_rows('team') ): $i = 0; ?>
<?php while( have_rows('team') ): the_row(); $i++;
$image = get_sub_field('image');
$position = get_sub_field('position');
$name = get_sub_field('name');
$bio = get_sub_field('bio');
?>
<div class="small-12 medium-4 large-4 columns" style="float: left;">
<div class="card">
<button class="teamInfo" id="wrap-<?php echo $i; ?>">
<div class="card-image">
<img class="img-responsive" style="width: 100%;" src="<?php echo $image; ?>">
</div>
<div class="card-content light-grey-bg">
<p class="card-title hind bold dark-grey caps"><span class="center"><?php echo $position; ?></span></p>
</div>
<div class="card-action blue-bg center text-center">
<p class="hind bold white caps"><?php echo $name; ?></p>
</div>
</button>
<div class="card-reveal" id="show-<?php echo $i; ?>">
<span class="card-title hind bold caps dark-grey"><?php echo $name; ?></span>
<button type="button" class="close" data-dismiss="modal" aria-label="Close" style="float: right !important;">
<span aria-hidden="true"><i class="fa fa-times blue" aria-hidden="true"></i></span>
</button>
<p class="hind dark-grey pt1"><?php echo $bio; ?></p>
</div>
</div>
</div>
<?php endwhile; ?>
<?php endif; ?>
And my function;
<script>
(function($) {
$('#wrap-1').on('click',function(){
$('#show-1').slideToggle('slow');
});
$('#show-1 .close').on('click',function(){
$('#show-1').slideToggle('slow');
});
})( jQuery );
</script>
Edit: the id is dynamically injected here;
id="wrap-<?php echo $i; ?>"
I would add the ID to each element in a data attribute, and use this and that ID to toggle appropriately. To summarize the JS, when you click on the button, you get the stored data attribute, which can be used to find the appropriate target for toggling.
To the HTML, I add the data ID to the #show divs, and removed the id completely from the button. It's not needed.
HTML changes:
<button class="teamInfo" data-toggle-id="<?php echo $i; ?>">
and
<div class="card-reveal" id="show-<?php echo $i; ?>" data-toggle-id="<?php echo $i; ?>">`
Javascript
(function($) {
$('.teamInfo').on('click', function() {
var id = $(this).data('toggle-id');
$('#show-' + id).slideToggle();
});
$('.card-reveal .close').on('click',function() {
var id = $(this).closest('.card-reveal').data('toggle-id');
$('#show-' + id).slideToggle('slow');
});
})( jQuery );
And the entire HTML as you posted it:
<div class="small-12 medium-4 large-4 columns" style="float: left;">
<div class="card">
<button class="teamInfo" data-toggle-id="<?php echo $i; ?>">
<div class="card-image">
<img class="img-responsive" style="width: 100%;" src="<?php echo $image; ?>">
</div>
<div class="card-content light-grey-bg">
<p class="card-title hind bold dark-grey caps"><span class="center"><?php echo $position; ?></span></p>
</div>
<div class="card-action blue-bg center text-center">
<p class="hind bold white caps"><?php echo $name; ?></p>
</div>
</button>
<div class="card-reveal" id="show-<?php echo $i; ?>" data-toggle-id="<?php echo $i; ?>">
<span class="card-title hind bold caps dark-grey"><?php echo $name; ?></span>
<button type="button" class="close" data-dismiss="modal" aria-label="Close" style="float: right !important;">
<span aria-hidden="true"><i class="fa fa-times blue" aria-hidden="true"></i></span>
</button>
<p class="hind dark-grey pt1"><?php echo $bio; ?></p>
</div>
</div>
</div>
I'd look at using this. You can still use a class for an event selector, and in the handler, have context to know which was selected.
<script>
(function($) {
$('.teamInfo').on('click',function(){
$(this).slideToggle('slow');
});
$('.teamInfo').on('click',function(){
$(this).slideToggle('slow');
});
})( jQuery );
</script>
^ i'm not clear if you were adding the .close class for a visual cue or if you wanted to use that to trach shown state. Might just need the one handler to act as a toggle. Or an if statement in the toggle if other things need to happen on the transition.
Magento v1.7
How can I submit a form in the header.phtml by listening for changes on a radio button?
This is my code, if I change the radio buttons to a select dropdown it submits fine. I can't understand
$groupId = null;
if (Mage::getSingleton('customer/session')->isLoggedIn()) {
/* Get the customer data */
$customer = Mage::getSingleton('customer/session')->getCustomer();
/* Get the customer's full name */
$customer = Mage::getModel('customer/customer')->load($customer->getId()) ;
$groupId = $customer->getGroupId();
}
$cookieGroupId = Mage::getModel('core/cookie')->get('customer_group_id');
if ($cookieGroupId) {
$groupId = $cookieGroupId;
}
?>
<div id="alt-nav-container">
<ul id="alt-nav">
<li class="icon-reorder"><span>Navigation</span></li>
</ul>
</div>
<div class="header-container">
<header class="header">
<h1>
<figure>
<a href="<?php echo $this->getUrl('') ?>" title="<?php echo $this->getLogoAlt() ?>" class="logo"><span><?php echo $this->getLogoAlt() ?></span>
</a>
</figure>
</h1>
<div class="player-container">
<div id="jquery_jplayer_1" class="jp-jplayer"></div>
<div id="jp_container_1" class="jp-audio">
<div class="jp-type-single">
<div class="jp-gui jp-interface">
<ul class="jp-controls">
<li class="control-left"><span class="play-button"></span><span class="pause-button"></span></li>
<li class="control-center"><strong>Playing: <span class="jp-track-title"></span></strong> by <span class="jp-composer-name"></span></li>
<li class="control-right"><span class="volume-on-button"></span><span class="volume-off-button"></span></li>
</ul>
<div class="jp-time-holder">
<div class="jp-current-time"></div>
<div class="jp-progress">
<div class="jp-seek-bar">
<div class="jp-play-bar"></div>
</div>
</div>
<div class="jp-duration"></div>
</div>
</div>
<div class="jp-no-solution">
<span>Update Required</span>
To play the media you will need to either update your browser to a recent version or update your Flash plugin.
</div>
</div>
</div>
</div>
<!--
<div style="z-index:9999;">
<?php
// var_export(get_class_methods(get_class($GroupId)));
?>
</div> -->
<div class="license-type">
<ul class="select-license-tab">
<li><span>Select your license type <sub class="icon-chevron-down"></sub></span>
<ul>
<li>
<div class="license-form">
<form action="<?php echo $this->getUrl('mcustomer/group/update') ?>" method="post" id="form-group-update" name="form-group-update">
<dl class="accordion">
<?php $groups = Mage::helper('customer')->getGroups()->toOptionArray(); ?>
<?php foreach($groups as $group){ ?>
<div class="license-item">
<dt>
<?php if($groupId != null && $group['value'] == $groupId):?>
<input id="license-type-<?php print $group['value'] ?>" name="validate-one-required" type="radio" value="<?php print $group['value'] ?>" class="required-entry validate-one-required" checked="checked" />
<label for="license-type-<?php print $group['value'] ?>"><?php print $group['label'] ?></label>
<?php else: ?>
<input id="license-type-<?php print $group['value'] ?>" name="validate-one-required" type="radio" value="<?php print $group['value'] ?>" class="required-entry validate-one-required" />
<label for="license-type-<?php print $group['value'] ?>"><?php print $group['label'] ?></label>
<?php endif; ?>
</dt>
<dd>
<?php print $group['customer_description'] ?>
</dd>
</div>
<?php } ?>
</dl>
</form>
</div>
</li>
</ul>
</li>
</ul>
</div>
</header>
</div>
<div class="navigation-bar">
<div class="navigation-bar-wrapper">
<?php echo $this->getChildHtml('topContainer'); ?>
<?php echo $this->getChildHtml('topSearch') ?>
<?php echo $this->getChildHtml('topLinks') ?>
<?php echo $this->getChildHtml('store_language') ?>
<?php echo $this->getChildHtml('topMenu') ?>
</div>
</div>
<script type="text/javascript">
//< ![CDATA[
var customForm = new VarienForm('form-group-update');
Event.observe($("validate-one-required"),'change', function(event){
$('form-group-update').submit();
});
//]]>
</script>
Thanks in advance
You should add a new class to your radio to prevent conflict with forms on other page since validate-one-required is not unique, or use more unique class selector eg $$('.license-form .validate-one-required').each..
$$('.license-form_radios').each(function(curInput) {
Event.observe(curInput, 'click', function() {
$('form-group-update').submit();
});
});
Right now I'm learning Opencart, and I'm trying to make my latest product display with jCarousel. I'm using Opencart 1.5.4.
This is what I've already tried, but still failed: http://www.packtpub.com/article/opencart-themes-using-jCarousel-plugin
I'm editing the latest.tpl file step-by-step as in the tutorial, but I'm getting stuck on the eight step.
When I open Firefox and hit refresh nothing happens, no error or message. This is my latest.tpl file:
<script type="text/javascript" src="catalog/view/javascript/jquery/jCarousel/js/jquery.jcarousel.min.js"></script>
<link rel="stylesheet" type="text/css" href="catalog/view/javascript/jquery/jCarousel/skins/tango/skin.css" />
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery('#latestcarousel').jcarouseljcarousel();
});
</script>
<div class="box">
<div class="box-heading"><?php echo $heading_title; ?></div>
<div class="box-content">
<div id="latestcarousel" class="box-product">
<?php foreach ($products as $product) { ?>
<div class="jCarousel-skin-tango">
<?php if ($product['thumb']) { ?>
<div class="image"><img src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>" /></div>
<?php } ?>
<div class="name"><?php echo $product['name']; ?></div>
<?php if ($product['price']) { ?>
<div class="price">
<?php if (!$product['special']) { ?>
<?php echo $product['price']; ?>
<?php } else { ?>
<span class="price-old"><?php echo $product['price']; ?></span> <span class="price-new"><?php echo $product['special']; ?></span>
<?php } ?>
</div>
<?php } ?>
<?php if ($product['rating']) { ?>
<div class="rating"><img src="catalog/view/theme/default/image/stars-<?php echo $product['rating']; ?>.png" alt="<?php echo $product['reviews']; ?>" /></div>
<?php } ?>
<div class="cart"><input type="button" value="<?php echo $button_cart; ?>" onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button" /></div>
</div>
<?php } ?>
</div>
</div>
</div>
Any suggestion?
This is what I do with latest.tpl file. It works now.
<link rel="stylesheet" type="text/css" href="catalog/view/javascript/jquery/jCarousel/skins/tango/skin.css" />
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery('#latestcarousel').jcarousel({
scroll: 1,
visible: 3,
auto: 3,
rtl: true,
wrap: 'circular'
});
});
</script>
<div class="box">
<div class="box-heading"><?php echo $heading_title; ?></div>
<div class="box-content">
<div class="box-product">
<ul id="latestcarousel" class="jcarousel-skin-tango">
<?php foreach ($products as $product) { ?>
<li class="carousel-latest">
<div class="image"><img src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>" /></div>
<div class="name"><?php echo $product['name']; ?></div>
<?php if ($product['price']) { ?>
<div class="price">
<?php if (!$product['special']) { ?>
<?php echo $product['price']; ?>
<?php } else { ?>
<span class="price-old"><?php echo $product['price']; ?></span> <span class="price-new"><?php echo $product['special']; ?></span>
<?php } ?>
</div>
<?php } ?>
</li>
<?php } ?>
</ul>
</div>
</div>
</div>
Thanks for anything.