jQuery code for automatic Increment the item depends on the date - php

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
<script type="text/javascript" src="jquery-ui.min.js"></script>
<link href="jquery-ui.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
$(function(){
var theDialog = $(".mydialog").dialog({
autoOpen: false,
resizable: false,
modal: true,
width: 'auto'
});
$('#one').click(function(){
theDialog.html('some random text').dialog('open');
});
$('#two').click(function(){
theDialog.html('<ul><li>Apple</li><li>Orange</li><li>Banana</li><li>Strawberry</li><li>long text string to see if width changes</li></ul>').dialog('open');
});
$('#three').click(function(){
//this is only call where off-centre is noticeable so use setTimeout
theDialog.html('<img src="./random.gif" width="500px" height="500px" />');
setTimeout(function(){ theDialog.dialog('open') }, 100);;
});
});
</script>
hi friends i have question, i have an iteam, no of 20 i want to add 2 item daily with the total item automatic, i need the jquery code , anyone can help me plz?

Related

Slick.js is not working due some conflict with the other scripts used on the page

I am using many scripts on my page but due to some reason slick.js script is not working with those scripts.
when i remove all the other string then slick is working fine.
Below is the body section
`
<body>
<section class="customer-logos slider">
<?php for ($i=0; $i<count($response['urlToImage']) ; $i++)
{
?>
<div class="slide">
<img src="<?php echo $response['urlToImage'][$i]; ?>"
height=200px
width=200px>
</div>
<?php }?>
</section>
</body>
ALL the scripts below please check which script is creating problem
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.3/jquery.min.js">
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/slick-
carousel/1.6.0/slick.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/slick-
carousel/1.6.0/slick.min.css" rel="stylesheet" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/slick-
carousel/1.6.0/slick-theme.min.css" rel="stylesheet" />
<script type="text/javascript">
$(document).ready(function(){
$('.customer-logos').slick({
slidesToShow: 6,
slidesToScroll: 1,
autoplay: true,
autoplaySpeed: 1500,
arrows: false,
dots: false,
pauseOnHover: false,
responsive: [{
breakpoint: 768,
settings: {
slidesToShow: 4
}
}, {
breakpoint: 520,
settings: {
slidesToShow: 3
}
}]
});
});
</script>
<script src="js/jquery.min.js"></script>
<script src="libs/bootstrap/js/bootstrap.min.js"></script>
<script src="js/wow.min.js"></script>
<script src="js/owl.carousel.js"></script>
<script src="js/smoothscroll.js"></script>
<script src="js/script.js"></script>
<script src="vendor/jquery.2.2.3.min.js"></script>
<script src="vendor/owl-carousel/owl.carousel.min.js"></script>
<script type="text/javascript" src="vendor/fancybox/dist/jquery.fancybox.min.js"></script>
<script src="js/1/theme.js"></script>
<script src="js/particles.min.js"></script>
<script src="js/particles.js"></script>`
Page loads three jquery scripts and two owl carousel scripts. It's not okay.
Leave only one jquery and one owl.
P.s slick must be loaded after jquery

Creating an alert box with a button connected to a link

Salutations! I would like to create an alert box which echo a button connected to a link. I would like to do the whole thing using php. I would like to put that piece of code in my codeigniter controller function.
Here is a piece of code that can echo a button connected to a link:
echo 'Add to Google Contacts';
Please help me to do my task. Thanks a lot.
Alert is a special kind of method which is only used for Showing some messages,with a button is attached.Only we can write text in it.If you want an alert box with your own components, design a new one yourself.But it will never become an alert box.By using jquery you can do this ..paste it.
Here is the Jquery code for dialog box,paste it.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style></style>
</head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js"></script>
<script src='template/js/jquery.textarea-expander.js'></script>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript">
// <---- VENTAÑAS DE PARAMETERES---->
$(document).ready(function() {
var regex,v,l,c,b,i,contapara=3;
$( "#wnd_Addparam" ).dialog({
autoOpen: false,
height: 'auto',
width: 350,
modal: true,
resizable:false,
buttons: {
"Link": function() {
location.href="http://www.google.com";
return false; },
Cancel: function() {
$( this ).dialog( "close" );
}
},
close: {}
});
$( "#wnd_Addparam" ).dialog( "open" );
});
</script>
<body>
<div id="wnd_Addparam" title="Information" ></div>
</body>
</html>
Hope this will help you dr..
You can use it with JavaScript to like,
echo "<a href='onclick='javascript:function(id)''></a>";
and the javascript you can use it by,
function(id)
{
window.location.href("file_name.php")
}
echo "<a href='#'><button onclick='".'alert("your alert message")'."'>Try it</button>";

echoing a jquery alert popup in php

I want to display a pop-up alert box upon some condition in PHP being satisfied. Something like:
echo "<script type="text/javascript"> alert('bleh'); </script>";
except using a custom jquery alert box. Is this possible??
I've tried something like:
echo "<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<script>
$(function() {
$( "#dialog-message" ).dialog({
modal: true,
buttons: {
Ok: function() {
$( this ).dialog( "close" );
}
}
});
});
</script>";
but it gives me a weird effect. Not pop up.
Thanks for your interest.
echo <<<EOD
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<script>
$("#dialog-message").dialog({
modal: true,
buttons: {
Ok: function() {
$( this ).dialog( "close" );
}
}
});
</script>
EOD;
Try something like this. Where $bleh is the PHP variable with the message to show.
<script type="text/javascript">
$(document).ready(function(){
var dlg = $('<div>').text(<?php echo $bleh ?>);
$(body).append(dlg);
dlg.dialog(
modal: true
);
});
<script>
PHP is expecting " (double quotes) in any lines like rel="stylesheet" to be php code. You have to either use ' (single quotes) or escape them with a function around the echo like add_slashes. To get around this, I generally use single quotes around echo contents, so all the double quotes are not bothered.
echo 'all the "quoted" stuff here';
Yes its possible..
echo "<script type=\"text/javascript\">alert('bleh');</script>";
but i am not sure if its a good way to write whole function in echo, Instead Define Your Function in HTML some where in your Page and echo the function name here like i did above..
as noted before you need to escape your character or use it like this so no need to escape characters in here
<?php if (condition == true) : ?>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<script>
$(function() {
$( "#dialog-message" ).dialog({
modal: true,
buttons: {
Ok: function() {
$( this ).dialog( "close" );
}
}
});
});
</script>
<?php endif; ?>
Sure thing. you probably want something around this:
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
//check for PHP condition. Script will only be output on condition pass.
<?php if(condition == true){ ?>
<script>
$(function() {
$("#dialog-message").dialog({
modal: true,
buttons: {
Ok: function() {
$(this).dialog("close");
}
}
});
});
</script>
<?php } ?>
basically, you don't actually need to 'echo' the script, as long as you're outputting it from a .php file and not an external .js file. the script will show up as long as the condition passes.

jqPlot label rendering not displaying correctly

I am using jqPlot to plot some data including dates and another user data identifier. I have it plotted correctly with this code (I'd post an image but I don't have the reputation yet!):
<link rel="stylesheet" type="text/css" href="css/jquery.jqplot.min.css" />
<script type="text/javascript" src="js/jquery-1.8.3.js"></script>
<script type="text/javascript" src="js/jquery.jqplot.min.js"></script>
<script type="text/javascript" src="js/plugins/jqplot.dateAxisRenderer.min.js"></script>
<script type="text/javascript" src="js/excanvas.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var line1=<?php echo $jqPlotArray;?>;
var plot2 = $.jqplot('line_chart', [line1], {
axes:{
xaxis:{
renderer:$.jqplot.dateAxisRenderer,
tickOptions:{formatString:'%b %y'}
}
},
series:[{color:'#01812a', lineWidth:1, markerOptions:{style:'filledCircle', color:'#01812a', size:'6'}}]
});
});
</script>
But when I try to format BOTH the axis labels to WHITE and a 9pt font it plots incorrectly with this code (Again, I'd post an image but can't yet):
<link rel="stylesheet" type="text/css" href="css/jquery.jqplot.min.css" />
<script type="text/javascript" src="js/jquery-1.8.3.js"></script>
<script type="text/javascript" src="js/jquery.jqplot.min.js"></script>
<script type="text/javascript" src="js/plugins/jqplot.dateAxisRenderer.min.js"></script>
<script type="text/javascript" src="js/plugins/jqplot.categoryAxisRenderer.min.js"></script>
<script type="text/javascript" src="js/excanvas.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var line1=<?php echo $jqPlotArray;?>;
var plot2 = $.jqplot('line_chart', [line1], {
axes:{
xaxis:{
renderer:$.jqplot.dateAxisRenderer,
renderer:$.jqplot.categoryAxisRenderer,
tickOptions:{formatString:'%b %y', textColor:'#FFFFFF', fontSize:'9pt'}
}
},
series:[{color:'#01812a', lineWidth:1, markerOptions:{style:'filledCircle', color:'#01812a', size:'6'}}]
});
});
</script>
In summary, my question is what renderers do I need and how to use them to simply format the x & y axis labels to a white font color (so the labels pop off my green background better) and also change the fontSize to 9pt.
Any help will be much appreciated.
Thanks
If your xaxis has dates, why are you trying to use the categoryAxisRenderer too?
I think the main problem is a missed capital letter:
renderer:$.jqplot.DateAxisRenderer //The D is Date is a capital
See fiddle here.

Jquery modal form is not working for me in PHP

Recently I'm starting to use jquery, when trying to popup a modal form using jquery its won't working for me, the css file and javascript files are keeping locally. Please see the code snippet below
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery-ui.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var $dialog = $('<div></div>')
.html('This dialog will show every time!')
.dialog({
autoOpen: false,
title: 'Basic Dialog'
});
$('#opener').click(function() {
alert('test');
$dialog.dialog('open');
// prevent the default action, e.g., following a link
return false;
});
});
</script>
</head>
<body>
<?php
echo '<link rel="stylesheet" type="text/css" href="jquery-ui.css">';
?>
<button id="opener">Open the dialog</button>
</body>
Please correct me if I did any mistake. Thanks all.
You need to include:
modal: true,
in your dialog definition like this:
var $dialog = $('<div></div>')
.html('This dialog will show every time!')
.dialog({
autoOpen: false,
modal: true,
title: 'Basic Dialog'
});

Categories