<form>
<table>
<tr>
<td>
<input type="tex" id="arheading" name="arheading" value="Article Heading" onfocus="if (this.value == 'Article Heading') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Article Heading';}" />
</td>
<td>
<select id="plaetype" name="placetype">
<option selected="Place Type">Place Type</option>
<?php
include 'ini/configs_adm.php';
$result_adm = mysql_query("SELECT * FROM places");
while($row_adm=mysql_fetch_array($result_adm))
{
echo '<option value="'.$row_adm['places'].'">'.$row_adm['places'].'</option>';
}
?>
</select>
</td>
<td>
<select id="country" name="country">
<?php
include 'ini/configs_adm.php';
$result_adm = mysql_query("SELECT * FROM countries");
while($row_adm=mysql_fetch_array($result_adm))
{
echo '<option value="'.$row_adm['country'].'">'.$row_adm['country'].'</option>';
}
?>
</select>
</td>
</tr>
</table>
</form>
Above is the code that i want to load on my index page without refreshing or without navigation through AJAX.
and the ajax code i tried to is.........
var loadedobjects = ""
var rootdomain = "http://" + window.location.hostname
function ajaxpage(url, containerid) {
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject) { // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
}
catch (e) {
try {
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e) {
}
}
}
else
return false
page_request.onreadystatechange = function () {
loadpage(page_request, containerid)
}
page_request.open('GET', url, true)
page_request.send(null)
}
function loadpage(page_request, containerid) {
if (page_request.readyState == 4 && (page_request.status == 200 || window.location.href.indexOf("http") == -1))
document.getElementById(containerid).innerHTML = page_request.responseText
}
function loadobjs() {
if (!document.getElementById)
return
for (i = 0; i < arguments.length; i++) {
var file = arguments[i]
var fileref = ""
if (loadedobjects.indexOf(file) == -1) { //Check to see if this object has not already been added to page before proceeding
if (file.indexOf(".js") != -1) { //If object is a js file
fileref = document.createElement('script')
fileref.setAttribute("type", "text/javascript");
fileref.setAttribute("src", file);
}
else if (file.indexOf(".css") != -1) { //If object is a css file
fileref = document.createElement("link")
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", file);
}
}
if (fileref != "") {
document.getElementsByTagName("head").item(0).appendChild(fileref)
loadedobjects += file + " " //Remember this object as being already added to page
}
}
}
and the code that will call for AJAX function is.....
<ul id="admin_menu">
<?php
include 'ini/configs_adm.php';
$result_adm = mysql_query("SELECT * FROM adm_tools");
while ($row_adm = mysql_fetch_array($result_adm))
{
echo '<li>' . $row_adm['adm_menu'] . '</li>';
}
?>
</ul>
My ajax code have loaded the page but the php script is not retrieving data from db
It looks like you might be missing the extract($row) function.
That would look like:
while($row_adm=mysql_fetch_array($result_adm))
{
extract($row_adm);
echo '<option value="'.$row_adm['places'].'">'.$row_adm['places'].'</option>';
}
Related
I'm working on a WordPress plugin which logs bruteforce attacks, but this is my second plugin ever and I'm unsure how to do this.
I grab the IP of the machine who is bruteforce attacking the wp-admin form by using guard_get_ip_address().
But now I'm stuck on how to save the actual IP at the moment of when the user is bruteforce attacking. Is there any way to save this to a table like I created below?
function logs() {
?>
<table>
<tr>
<th>IP</th>
</tr>
<tr>
<td><?php echo guard_get_ip_address(); ?></td>
</tr>
</table>
<?php
}
function add_logs() {
wp_add_dashboard_widget('dashboard_widget', 'Logs', 'logs');
}
add_action('wp_dashboard_setup', 'add_logs' );
Edit: the function guard_get_ip_address() only attempts to grab IPs;
function guard_get_ip_address() {
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
return $ip;
}
// LOG DATA WILL STORE IN FOLDER WITH YOURFILENAME.DOC USE TO PRINT THIS CODE , CALL THIS FUNCTION WITH ANCHOR TAG FROM YOUR VIEW PAGE
public function file_log()
{
$id = YOURFILENAME;
$file = APPPATH.'yourfile/'.$id.'.doc';
$content = file_get_contents($file);
echo '<html><body style="background-color:white; padding-
left:20px; padding-top:40px;">'.$content.'</body></html>';
}
// create Base.php file
function get_file_force_contents($contents,$LogfileName,$logUserName){
if($contents){
date_default_timezone_set("Asia/Kolkata");
$logtime = Date('d-M-Y h:i A');
$dir = APPPATH.'yourfile/';
#$file = $dir.'/'.$LogfileName.'.doc';
if(!is_dir($dir)) mkdir($dir, 0777, TRUE);
#$current = file_get_contents(#$file);
$current .= '<br>'.$logtime.' - '.'<strong>'.$logUserName.'</strong> - '.$contents;
file_put_contents($file, $current);
}
}
// controller
require_once(APPPATH.'/Base.php');
function log{
$logUserName = 'logged in UserName';
$LogfileName = YourFILEName;
$LogData = json_decode($this->input->post('something1'), true);
$LogArray = array();
if(is_array($LogData)){
foreach($LogData as $key => $log){
foreach($log as $key1 =>$v){
$LogArray[$key1] = $v;
}
}
$array = array_unique($LogArray, SORT_REGULAR);
foreach ($array as $key => $value) {
$output = $value."<br>";
$contents = $output;
//print_r($contents);
get_file_force_contents($contents,$LogfileName,$logUserName);
}
}
}
// your jquery code
// for input change start
<script type="text/javascript">
var arr = [];
var InputPrevVal;
var InputCurrentVal;
$("input").on("focus",function () {
}).change(function() {
var InputID = $(this).attr('id');
var InputPrevVal = $('#'+InputID).attr('value');
var InputCurrentVal = $(this).val();
if(InputID == 'refrence_name'){
var ValueChangesForInput = 'Enquiry Person: ';
var value = $('#something').html('Updated '+ValueChangesForInput+' '+InputPrevVal+' To '+InputCurrentVal);
arr.push({Reference_Name:$('#something').val()});
}
$('#something1').val(JSON.stringify(arr));
//console.log('Input Changes : '+InputPrevVal+' To '+InputCurrentVal);
});
// for dropdown
var PreviousValue;
var SelectedIdChng;
$("select").on("focus",function () {
var SelectedId = $(this).attr("id");
var PreviousValue = $(this).attr("attr");
}).change(function() {
var SelectedIdChng = $(this).attr("id");
var CurrentValue = $(this).find("option:selected").text();
var PreviousValue = $(this).attr("attr");
if(SelectedIdChng == 'destination'){
var ValueChangesFor = 'Destination: ';
var value = $('#something').html('Updated '+ValueChangesFor+'
'+PreviousValue+' To '+CurrentValue);
arr.push({Destination:$('#something').val()});
}
console.log(arr);
$('#something1').val(JSON.stringify(arr));
});
</script>
// VIEW PAGE
<textarea id="something" name="something" class="" style="width:
1300px; height: 100px;">
</textarea>
<textarea id="something1" name="something1" class=""
style="width: 1300px; height: 100px;"></textarea>
<select name="destination" id="destination" required="" attr="At your
works/Door Delivery">
<option value="">Select</option>
<option value="1" selected="">At your works/Door Delivery</option>
<option value="2">At our works</option>
<option value="3">Godown Delivery</option>
</select>
<input type="text" class="form-control valid" name="refrence_name"
id="refrence_name" placeholder="refrence_name" value="Sonu Vishwakarma">
Sorry, I misunderstood the question.
in your plugin, you will need to save the server data into a javascript element, in which you can use JQUERY to execute.
The fastest way I know in my head at the moment is Cookies.
Create a cookie in PHP and pull it in JS:
$cookie_name = "IP";
$cookie_value = "127.0.0.1"; //add your value here
setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/"); // 86400 = 1 day
var x = document.cookie;
from there, you can use JQUERY to add to the table:
$('tableid tr:first td').html(x);
I am trying to open an XML file with Ajax. Its responseText is working fine but responseXML is returning null. I checked the syntax, there is nothing wrong with the syntax. I don't know what the problem is. Here is my code...
My HTML code
<div id='albumBox'>
<input type='file' multiple name='newsfeedAlbum[]' id='newsfeedAlbum' onchange='uploadNewsfeedImages()' />
</div>
<div id='uploadingImages'>
<progress id='newsfeedImageProgressBar'></progress>
</div>
<div>
<input type='button' id='albumButton' value='post' />
</div>
my JavaScript codeā¦
function uploadNewsfeedImages()
{
//alert("loaded");
var files = document.getElementById("newsfeedAlbum").files;
var formData = new FormData();
var unixTimeStamp = Math.floor(((new Date).getTime())/1000);
formData.append("action","post");
formData.append("thing","album");
formData.append("unixTimeStamp",unixTimeStamp);
formData.append("album_to","news_feed");
for(var i = 0;i < files.length;i++)
{
var file = files[i];
//alert("file name is "+files.item(i).name);
formData.append("albumImages[]",file);
}
var xhr = new XMLHttpRequest();
xhr.open("POST","add_newsfeed.php",true);
xhr.onreadystatechange = function()
{
if(xhr.readyState == 4)
{
//alert(xhr.responseText);
alert(xhr.responseXML);
}
}
xhr.upload.onprogress = function(event)
{
showProgress(xhr,event);
}
xhr.send(formData);
}
function showProgress(xhr,event)
{
var uploaded = event.loaded/event.total;
uploaded = Math.floor(uploaded*100);
//alert(uploaded);
document.getElementById("newsfeedImageProgressBar").value = uploaded;
}
Here is my php code...
session_start();
echo '<?xml version="1.0" encoding="UTF-8"?>';
header("Content-type: text/xml");
if(isset($_POST))
{
echo "<newsfeed>";
$action = $_REQUEST["action"];
if($action == "post")
{
$thing = $_REQUEST["thing"];
if($thing == "text")
{
}
elseif($thing == "album")
{
$succeded = array();
$failed = array();
$targetFolder = "images/";
$extensions = array("jpeg","jpg","bmp","png","gif");
foreach($_FILES["albumImages"]["name"] as $key=>$value)
{
//echo $key."=>".$value."<br />";
if($_FILES["albumImages"]["error"][$key] === 0)
{
$extension = strtolower(pathinfo($value,PATHINFO_EXTENSION));
if(in_array($extension,$extensions))
{
$source = $_FILES["albumImages"]["tmp_name"][$key];
$destination = $targetFolder.basename($value);
if(move_uploaded_file($source,$destination))
{
$succeded[] = $value;
}
else
{
$failed[] = $value;
}
}
else
{
$failed[] = $value;
}
}
else
{
$failed[] = $value;
}
}
if(count($succeded)>0)
{
echo "<succeded>";
for($i=0;$i<count($succeded);$i++)
{
echo "<succeded_file>".$succeded[$i]."</succeded_file>";
}
echo "</succeded>";
}
if(count($failed)>0)
{
echo "<failed>";
for($i=0;$i<count($failed);$i++)
{
echo "<failed_file>".$failed[$i]."</failed_file>";
}
echo "</failed>";
}
}
}
echo "</newsfeed>";
}
?>
It's probably because the content type of the file coming back from the sever is not xml.
Try using header('Content-Type: text/xml'); in your PHP code.
I want to display custom option price with name in price box in product detail page.
I also try this link but not getting success this is link i use
So please suggest me any solution.
first of all you have to put button calculateprice
then onclick of calculateprice you have to call function chkprice()
function chkpice()
{
var a=document.getElementById("options_1_text").value;
var b=document.getElementById("options_2_text").value;
var c=document.getElementById("options_3_text").value;
var d=document.getElementById("options_4_text").value;
var e=<?php echo $_product = $this->getProduct()->getPrice()?>;
var f=(a+b+c+d)+e;
var e=document.getElementById(('product-price-'+<?php echo $_product = $this->getProduct()->getId()?>)).innerHTML;
$('product-price-'+<?php echo $_product = $this->getProduct()->getId()?>).innerHTML =''+e.replace(<?php echo $_product = $this->getProduct()->getPrice()?>,d)+'</span>';
}
insted of options_1_text,options_2_text,options_3_text,options_4_text put your id it will get your result
First you do the function that takes care of updating the charges:
function updateCharges(){
var tmpText="";
$("input[type='select']").each(function{
tmpText+=$("#"+this.id+"option:selected").text()+"<br>";
});
$("#detailDiv").html(tmpText)
}
Then you just bind the selects to that function
$("input[type='select']").change(updateCharges)
Now you just have to make sure to include in your template a <div id="detailDiv"></div>
I would just create a custom block with the above code and place it inside the product detail page. Also you should check the selectors used, they will look for absolutelty ALL selects on the page, so thats not what you may want. But its just a matter of firebug-ging untill the aproppiate selector is found
Recently I need something similar. Perhaps it is helpful for you.
Block class:
class Foo_Bar_Block_Baz extends Mage_Catalog_Block_Product_View {
protected function getOptionDataCollection($options) {
$optionDataCollection = array();
foreach ($options as $option) {
$optionDataCollection[$option->getData('option_id')] = array_filter($option->getData());
}
return $optionDataCollection;
}
protected function getOptionValueDataCollection($options) {
$optionValueDataCollection = array();
foreach ($options as $option) {
$optionType = $option->getType();
if ($optionType == 'drop_down') {
$optionValues = $option->getValues();
foreach ($optionValues as $valueItem) {
// here you could also use the option_type_id (in my case I needed the sku)
$optionValueDataCollection[$valueItem->getData('sku')] = array_filter($valueItem->getData());
}
} else {
//Mage::throwException('Unexpected input. Processing for this optionType is not implemented');
}
}
return $optionValueDataCollection;
}
public function getOptionsJson() {
$data = array(
'options' => array(),
'optionValues' => array()
);
$options = $this->getProduct()->getOptions();
array_push($data['options'], $this->getOptionDataCollection($options));
array_push($data['optionValues'], $this->getOptionValueDataCollection($options));
$optionsJson = json_encode($data);
return $optionsJson;
}
}
Template
<script id="optionsJson" type="application/json">
<?php echo $this->getOptionsJson(); ?>
</script>
JS
var json = JSON.parse(document.getElementById("optionsJson").innerHTML),
options = json.options[0],
optionValues = json.optionValues[0];
optionValues['<optionValueSKU>'].default_title
optionValues['<optionValueSKU>'].price
-----------Create controller-------------
<?php
class Magento_Guys_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
echo "Thank you !";
}
public function genCartAction()
{
$id = $this->getRequest()->getParam('pid');
$_product = Mage::getModel('catalog/product')->load($id);
$buy = Mage::helper('checkout/cart')->getAddUrl($_product);
echo $qty = (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty();
//echo $id;
//echo $this->getRequest()->getParam('id');;
}
}
?>
----------------Change Add to cart code-------------------
<?php if ($_product->isAvailable()): ?>
<b class="available_quanity" style="display: none">Available Quantity :</b> <span id="simplestock" class="simplestock">Please select a color to view the quantity</span>
<?php endif; ?>
</div>
<?php if(!$_product->isGrouped()): ?>
<div class="qty">
<label for="qty"><?php echo $this->__('Qty:') ?></label>
<?php $i = 0; ?>
<select id="qty" class="input-text" name="qty" style="width:50px;">
<?php while($i<=(int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty()):?>
<option value="<?php echo $i; ?>"><?php echo $i++; ?></option>
<?php endwhile; ?>
</select>
</div>
<?php endif; ?>
----------------Add Ajax for get Quantity---------------
<script>
jQuery(document).ready(function() {
jQuery(".product-options select[id^='attribute']").on('change', function() {
var id = getSimpleProductId();
var qty = "";
jQuery('.available_quanity').show();
jQuery("#fancybox-loading").show();
jQuery.ajax({
type: "POST",
data: 'pid=' + id,
url:'https://www.thewirelesscircle.com/guys/index/genCart',
success:function(response){
if (response) {
qty = response;
var x = document.getElementById("qty");
var i;
removeOptions(x);
for(i=1;i<=qty;i++) {
var option = document.createElement("option");
option.text = i;
option.value = i;
x.add(option);
}
}
jQuery("#fancybox-loading").hide();
}
});
});
});
</script>
---------------Get Selected Option Id in Magento-------------------
<script type="text/javascript">
function removeOptions(selectbox)
{
var i;
for(i = selectbox.options.length - 1 ; i >= 0 ; i--)
{
selectbox.remove(i);
}
}
function getSimpleProductId() {
var productCandidates = [];
jQuery.each(spConfig.settings, function (selectIndex, select) {
var attributeId = select.id.replace('attribute', '');
var selectedValue = select.options[select.selectedIndex].value;
jQuery.each(spConfig.config.attributes[attributeId].options, function(optionIndex, option) {
if (option.id == selectedValue) {
var optionProducts = option.products;
if (productCandidates.length == 0) {
productCandidates = optionProducts;
} else {
var productIntersection = [];
jQuery.each(optionProducts, function (productIndex, productId) {
if (productCandidates.indexOf(productId) > -1) {
productIntersection.push(productId);
}
});
productCandidates = productIntersection;
}
}
});
});
return (productCandidates.length == 1) ? productCandidates[0] : null;
}
</script>
Open page: app\code\core\Mage\Catalog\Block\Product\View\Options.php find protected function _getPriceConfiguration($option) function and add $data['title'] = $option->getTitle(); before return $data; statement.
Now, open app\design\frontend\YOUT_TEMPLATE_PATH\default\template\catalog\product\view\options.phtml
Add <div id="optiontitle"></div> top of the page.
Then find this:
$A(element.options).each(function(selectOption){
if ('selected' in selectOption && selectOption.selected) {
if (typeof(configOptions[selectOption.value]) != 'undefined') {
curConfig = configOptions[selectOption.value];
}
}
});
Replace by:
$A(element.options).each(function(selectOption){
if ('selected' in selectOption && selectOption.selected) {
if (typeof(configOptions[selectOption.value]) != 'undefined') {
curConfig = configOptions[selectOption.value];
optionTitle = curConfig.title + "<br>";
$("optiontitle").insert(optionTitle);
}
}
});
I am using Ajax to populate a drop down menu from the database, my question is how do I onclick redirect it to a page along with the CARD_ID i got back from the database?
right now when I click on it it's displaying the card name in the search bar which is part of what I want but now I need the other half the redirection. How can I achieve this?
<?php
$mysqli = mysqli_connect('localhost', 'root', '', 'draftdb');
if(mysqli_connect_errno())
{
echo "Connection Failed: " . mysqli_connect_errno();
exit();
}
$str = $_GET['content'];
if(strlen($str))
{
$sel = mysqli_query($mysqli, "select CARD_NAME, CARD_ID,CARD_TYPE from cards where CARD_NAME like '".trim($str)."%'");
if(mysqli_num_rows($sel))
{
echo "<table border =\"0\" width=\"100%\">\n";
if(mysqli_num_rows($sel))
{
echo "<script language=\"javascript\">box('1');</script>";
while($row = mysqli_fetch_array($sel))
{
$card_info = str_ireplace($str,"<b>".$str."</b>",($row['CARD_NAME']));
$card_type = str_ireplace($str,"<b>".$str."</b>",($row['CARD_TYPE']));
echo "<tr id=\"word".$row['CARD_ID']."\" onmouseover=\"highlight(1,'".$row['CARD_ID']."');\" onmouseout=\"highlight(0,'".$row['CARD_ID']."');\" onClick=\"display('".$row['CARD_NAME']."');\" >\n<td>".$card_info." ".$card_type."</td>\n</tr>\n";
}
}
echo "</table>";
}
}
else
{
echo "<script language=\"javascript\">box('0');</script>";
}
?>
the javascript.
subject_id = '';
function handleHttpResponse() {
if (http.readyState == 4) {
if (subject_id != '') {
document.getElementById(subject_id).innerHTML = http.responseText;
}
}
}
function getHTTPObject() {
var xmlhttp;
/*#cc_on
#if (#_jscript_version >= 5)
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
#else
xmlhttp = false;
#end #*/
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp = false;
}
}
return xmlhttp;
}
var http = getHTTPObject(); // We create the HTTP Object
function getScriptPage(div_id,content_id)
{
subject_id = div_id;
content = document.getElementById(content_id).value;
http.open("GET", "script_page.php?content=" + escape(content), true);
http.onreadystatechange = handleHttpResponse;
http.send(null);
if(content.length>0)
box('1');
else
box('0');
}
function highlight(action,id)
{
if(action)
document.getElementById('word'+id).bgColor = "#C2B8F5";
else
document.getElementById('word'+id).bgColor = "#F8F8F8";
}
function display(word)
{
document.getElementById('text_content').value = word;
document.getElementById('box').style.display = 'none';
document.getElementById('text_content').focus();
}
function box(act)
{
if(act=='0')
{
document.getElementById('box').style.display = 'none';
}
else
document.getElementById('box').style.display = 'block';
}
the html
<div class="ajax-div">
<div class="searchbar">
<input type="text" onKeyUp="getScriptPage('box','text_content')" id="text_content">
</div>
<div id="box"></div>
</div>
I'm not sure what you are trying to do, but it seems you want something like this:
1- Change the way you display your rows so that the ID gets sent to your function as well:
echo "<tr id=\"word".$row['CARD_ID']."\" onmouseover=\"highlight(1,'".$row['CARD_ID']."');\" onmouseout=\"highlight(0,'".$row['CARD_ID']."');\"
onClick=\"display('".$row['CARD_NAME']."', " . $row['CARD_ID'] . ");\" >\n<td>".$card_info." ".$card_type."</td>\n</tr>\n";
^^^^^^^^^^^^^^^^^^^^^^^^^
2- Change your display function to redirect
function display(word, id)
{
// document.getElementById('text_content').value = word;
// document.getElementById('box').style.display = 'none';
// document.getElementById('text_content').focus();
window.location.href = "some_page.php?card_id=" + id;
}
I have commented out the original lines because there doesn't seem much point in doing stuff on a page you are leaving anyway. You could also completely remove the word parameter if this is the solution you are looking for.
i have a problem on the slider of my site, though the slider works fine and good but i need it to be random or shuffle instead of displaying an ordered content..
i already have the code and it need some modification.
this is the line on the main file.php
<script type="text/javascript">
$(document).ready(function() {
$('#slider1').s3Slider({
timeOut: 8000
});
});
<div id="slider1">
<ul id="slider1Content">
<li class="slider1Image">
<img src="products/1.png" alt="1" />
<span class="left">
caption1
</span>
</li>
<li class="slider1Image">
<img src="products/2.png" alt="2" />
<span class="right">caption2
</span>
</li>
<li class="slider1Image">
<img src="products/3.png" alt="3" />
<span class="right">caption3.
</span>
</li></div>
this is the java script file
(function($){
$.fn.s3Slider = function(vars) {
var element = this;
var timeOut = (vars.timeOut != undefined) ? vars.timeOut : 4000;
var current = null;
var timeOutFn = null;
var faderStat = true;
var mOver = false;
var items = $("#" + element[0].id + "Content ." + element[0].id + "Image");
var itemsSpan = $("#" + element[0].id + "Content ." + element[0].id + "Image span");
items.each(function(i) {
$(items[i]).mouseover(function() {
mOver = true;
});
$(items[i]).mouseout(function() {
mOver = false;
fadeElement(true);
});
});
var fadeElement = function(isMouseOut) {
var thisTimeOut = (isMouseOut) ? (timeOut/2) : timeOut;
thisTimeOut = (faderStat) ? 10 : thisTimeOut;
if(items.length > 0) {
timeOutFn = setTimeout(makeSlider, thisTimeOut);
} else {
console.log("Poof..");
}
}
var makeSlider = function() {
current = (current != null) ? current : items[(items.length-1)];
var currNo = jQuery.inArray(current, items) + 1
currNo = (currNo == items.length) ? 0 : (currNo - 1);
var newMargin = $(element).width() * currNo;
if(faderStat == true)
{
if(!mOver) {
$(items[currNo]).fadeIn((timeOut/6), function() {
if($(itemsSpan[currNo]).css('bottom') == 0) {
$(itemsSpan[currNo]).slideUp((timeOut/6), function() {
faderStat = false;
current = items[currNo];
if(!mOver) {
fadeElement(false);
}
});
} else {
$(itemsSpan[currNo]).slideDown((timeOut/6), function() {
faderStat = false;
current = items[currNo];
if(!mOver) {
fadeElement(false);
}
});
}
});
}
} else {
if(!mOver) {
if($(itemsSpan[currNo]).css('bottom') == 0) {
$(itemsSpan[currNo]).slideDown((timeOut/6), function() {
$(items[currNo]).fadeOut((timeOut/6), function() {
faderStat = true;
current = items[(currNo+1)];
if(!mOver) {
fadeElement(false);
}
});
});
} else {
$(itemsSpan[currNo]).slideUp((timeOut/6), function() {
$(items[currNo]).fadeOut((timeOut/6), function() {
faderStat = true;
current = items[(currNo+1)];
if(!mOver) {
fadeElement(false);
}
});
});
}
}
}
}
makeSlider();
};})(jQuery);
i am struggling modifying this script for almost a week ... please help
Not sure if your still looking for a solution... I've just done this, but thought it would have been a better method to write the li tags out server side by calling them from a random array. That's if your using server side scriptiing - Below is what I did in php.
$arr = array("
Some text", "
Some text", "
Some text", );
$arrCnt = count($arr);
for ($i=0; $i<=$arrCnt; $i++)
{
$random = array_rand($arr);
echo "<li class='sliderImage'>";
echo $arr[$random];
echo "</li>\n";
if($i<$arrCnt-1)
unset($arr[$random]);
}
?>
Hope that helps.