Jump to content


  • Posts

  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

lional's Achievements

Advanced Member

Advanced Member (4/5)



  1. Hi, thanks, did some rough calculations and that should work, thanks a million
  2. Hi I am busy with a word press and I need to add leading zeros to a number in javascript so that for example 9 becomes 0.00009, and 30 becomes 0.00030 and 560 becomes 0.00560. I am very new to Javascript. I have been looking at the pad left functions. Is this the correct function or is there another one. Any help will be much appreciated
  3. Thanks for your input, I made some alterations since my post, still not working but I think I am closer. I moved my functions to the functions.php in my theme. Here are my two functions function getTierBLOne() { global $wpdb; $maincats = $wpdb->get_results( "SELECT * FROM nova_tp_forex_main_cats ORDER BY forex_name ASC" ); //$result_query = mysqli_query($conn,"SELECT * FROM nova_tp_forex_main_cats ORDER BY forex_name ASC"); //while ($tier = mysqli_fetch_array($result_query)) foreach($maincats as $maincat) { echo '<option value="' . $maincat->forex_id .'">'.$maincat->forex_name.'</option>'; } } if (isset($_GET['func'])&& $_GET['func'] == 'drop_bl' ) { drop_bl($_GET['drop_var']); } function drop_bl($drop_var) { global $wpdb; $subcats = $wpdb->get_results( "SELECT * FROM nova_tp_forex_main_subcats WHERE forex_main_cat = '$drop_var' ORDER BY forex_subcat_name"); echo '<select name="drop_2" id="drop_2"> <option value=" " disabled="disabled" selected="selected">Choose one</option>'; foreach($subcats as $subcat) { echo '<option value="'.$subcat->forex_subcat_id.'">'.$subcat->forex_subcat_name.'</option>'; } echo '</select> '; } Here is the latest version of my js file jQuery(document).ready(function() { jQuery('#wait_bl').hide(); jQuery('#drop_bl').change(function(){ alert( "Handler for .change() called." ); jQuery('#wait_bl').show(); jQuery('#result_bl').hide(); jQuery.post( nova_ajax_script.ajax_url, { action: "drop_bl", drop_var: jQuery('#drop_bl').val() }, function(response) { $('#result_bl').fadeOut(); setTimeout("finishAjax('result_bl', '"+escape(response)+"')", 400); }, )} ); }); function finishAjax(id, response) { jQuery('#wait_bl').hide(); jQuery('#'+id).html(unescape(response)); jQuery('#'+id).fadeIn(); } And here is my final plugin file <?php function js_enqueue_scripts() { wp_register_script('nova_ajax_script', plugins_url('js/nova-ajax.js', __FILE__), array('jquery'), null, true); wp_localize_script( 'nova-script', 'nova_ajax_script', array( 'ajax_url' => admin_url('admin-ajax.php')) ); } add_action( 'wp_enqueue_scripts', 'js_enqueue_scripts' ); function nova_options_page() { // Add top level admin menu add_menu_page('Nova Trade Signal', 'Nova Trade Signal', 'manage_options', 'nova', 'add_nova_trade_signal_html', plugins_url('Nova-Trade-Signals/images/icon_admin.jpg')); add_submenu_page('nova', 'Add Trade Signal', 'Add Trade Signal', 'manage_options', 'add_nova_trade_signal', 'add_nova_trade_signal_html'); add_submenu_page('nova', 'Update Trade Signal', 'Update Trade Signal', 'manage_options', 'update_nova_trade_signal', 'update_nova_trade_signal_html'); } /** * register our tv_options_page to the admin_menu action hook */ add_action('admin_menu', 'nova_options_page'); /** *function page for output of adding trade signal */ function add_nova_trade_signal_html() { ?> <select name="drop_bl" id="drop_bl" style="margin-top:0px;margin-left:35px"> <option value="" selected="selected" disabled="disabled">Select a Province</option> <?php getTierBLOne(); ?> </select> <span id="wait_bl" style="display: none;"> </span> <span id="result_bl" style="display: none;"></span> <?php } add_action('wp_ajax_drop_bl', 'drop_2'); add_action('wp_ajax_no_priv_drop_bl', 'drop_2'); ?>
  4. Sorry, I have another function page <?php //************************************** // Page load dropdown results // //************************************** function getTierBLOne() { include 'includes/conn_db.php'; $result_query = mysqli_query($conn,"SELECT * FROM nova_tp_forex_main_cats ORDER BY forex_name ASC"); while ($tier = mysqli_fetch_array($result_query)) { echo '<option value="'.$tier['forex_id'].'">'.$tier['forex_name'].'</option>'; } } //************************************** // First selection results // //************************************** if (isset($_GET['func'])&& $_GET['func'] == 'drop_bl' ) { drop_1($_GET['drop_var']); } function drop_1($drop_var) { include_once('includes/conn_db.php'); $result_query = mysqli_query($conn,"SELECT * FROM nova_tp_forex_main_cats WHERE forex_main_cat = '$drop_var' ORDER BY forex_subcat_name"); echo '<select name="drop_2" id="drop_2"> <option value=" " disabled="disabled" selected="selected">Choose one</option>'; while($drop_2 = mysqli_fetch_array($result_query)) { echo '<option value="'.$drop_2['forex_subcat_id'].'">'.$drop_2['forex_subcat_name'].'</option>'; } echo '</select> '; } ?> So what effectively happens (or suppose to happen) is the plugin page goes to this page to pull initial drop down data, then on change the ajax calls the next function to populate the second drop down
  5. Hi All I am trying to write chained selects for a WordPress plugin I am busy with. I have been struggling with it for a few days because my ajax is very weak. This is my file plugin file: <?php function js_enqueue_scripts() { wp_enqueue_script ("nova-ajax-handle", get_stylesheet_directory_uri() . "js/nova-ajax.js", array('jquery')); //the_ajax_script will use to print admin-ajaxurl in custom ajax.js wp_localize_script('nova-ajax-handle', 'nova_ajax_script', array('ajaxurl' =>admin_url('admin-ajax.php'))); } add_action("wp_enqueue_scripts", "js_enqueue_scripts"); ?> <select name="drop_bl" id="drop_bl" style="margin-top:0px;margin-left:35px"> <option value="" selected="selected" disabled="disabled">Select a Province</option> <?php getTierBLOne(); ?> </select> <span id="wait_bl" style="display: none;"> </span> <span id="result_bl" style="display: none;"></span> My Javascript file looks like this: $(document).ready(function() { $('#wait_bl').hide(); $('#drop_bl').change(function(){ $('#wait_bl').show(); $('#result_bl').hide(); $.ajax({ url: nova_ajax_script,ajax_url, type: get, func: "drop_bl", drop_var: $('#drop_bl').val() }), function(response) { $('#result_bl').fadeOut(); setTimeout("finishAjax('result_bl', '"+escape(response)+"')", 400); } return false; }); }); function finishAjax(id, response) { $('#wait_bl').hide(); $('#'+id).html(unescape(response)); $('#'+id).fadeIn(); } When I select my first dropdown, it does not fire up the second one. This is my very first attempt at WordPress development, so I might be making many errors Thank you
  6. Hi All I am trying to write a page to have a similar effect as the following page http://www.pht.co.za/about.php Is there tutorials that I can have a look at to figure out how to accomplish it. I have been trying to do it but my main problem is that when I hover over a menu item on the left the content must change and that content must remain until I hover over a new menu item. I am not asking that this be done for me because then I will not learn just to point me in the right direction Any help will be appreciated
  7. Thanks, I will look and see why it is doing that and try to rectify it
  8. Hi All I am converting my scripts from mysql to mysqli and I am having some difficulty $query = mysqli_query($conn,"SELECT * FROM products WHERE prod_id IN ("); foreach ($_SESSION['cart'] as $key => $value) { $query .= $key . ','; } $query = substr ($query, 0, -1) . ')'; $result = mysqli_query($conn, $query) or die(mysqli_error($conn)); while ($row = mysqli_fetch_array($query, MYSQLI_ASSOC)) { } I get the following error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1111)' at line 1 I have tried to change it with my limited knowkledge. I am not asking for the answer just to point me in the right direction. Any help will be appreciated
  9. Hi I am struggling a bit to convert mysql to mysqli and some things don't seem to be working and I have been battling for hours I have this code that gives me the following error message Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given while (($row = mysqli_fetch_assoc($result)) !== false) { $names[$row['user_name']] = $row['user_id']; return $names; } Thank you in advance
  10. Hi All I am busy changing from mysql to mysqli on my old scrips and I have one problem that I cannot seem to solve. <?php // checks a given username and password combination. function validate_credentials($user_name, $user_password) { $conn = mysqli_connect("localhost", "root", "", "hebron_college"); /*@mysql_select_db('hebron_college');*/ $user_name = mysqli_real_escape_string($conn, $user_name); $user_password = sha1($user_password); $result = mysqli_query($conn, "SELECT * FROM users WHERE user_name = '$user_name' AND user_password = '$user_password'"); $num = mysqli_num_rows($result); echo 'number' . $num; if (mysqli_num_rows($result) != 1){ return false; } return mysqli_result($result, 0); } ?> I have done some research and I believe there is no mysqli_result function. How would I be able to replace the mysql_result line in mysqli
  11. Hi I found this facebook like messaging system tutorial that seems to be just but what I need, however when I press the reply button to send the new message it seems to be stuck on that page I am attaching all the related code. The Script.js looks like this $(document).ready(function(){ /*post message via ajax*/ $("#reply").on("click", function(){ var message = $.trim($("#message").val()), conversation_id = $.trim($("#conversation_id").val()), user_form = $.trim($("#user_form").val()), user_to = $.trim($("#user_to").val()), error = $("#error"); if((message != "") && (conversation_id != "") && (user_form != "") && (user_to != "")){ error.text("Sending..."); $.post("post_message_ajax.php",{message:message,conversation_id:conversation_id,user_form:user_form,user_to:user_to}, function(data){ error.text(data); //clear the message box $("#message").val(""); }); } }); //get message c_id = $("#conversation_id").val(); //get new message every 2 second setInterval(function(){ $(".display-message").load("get_message_ajax.php?c_id="+c_id); }, 2000); $(".display-message").scrollTop($(".display-message")[0].scrollHeight); }); I am sure it is something smaal, I have been looking at it for a few hours now and I will continue to look to see if I can solve the problem get_message_ajax.php index.php logout.php message.php post_message_ajax.php
  12. Hi All I am trying to create a modal popup but I would like it to do the following 1. Load when the user enters the site, but only once not every time they navigate to a new page. 2. when they leave the site. again only when they leave the site not when they move from page to page. I am still busy on number 1 so I haven't started working on nr 2. I have got the popup part right but it loads every time the page is refreshed. I have been trying to play with cookies but then it doesn't load at all <script> if (once_per_session==0) $(document).ready(function() { if ($.cookie('20080521') != '1') { $('#myModal').modal('show'); $.cookie('20080521', '1', { domain: '', path: '' }); } }); </script> <div class="modal fade" id="myModal" role="dialog"> <div class="modal-dialog"> <!-- Modal content--> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">×</button> <h4 class="modal-title">Modal Header</h4> </div> <div class="modal-body"> <p>Some text in the modal.</p> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> </div> </div> </div> </div> <style> .modal{ position:fixed; top:0; right:0; bottom:0; left:0; z-index:1050; display:none; overflow:hidden; -webkit-overflow-scrolling:touch; outline:0 } .modal.fade .modal-dialog{ -webkit-transition:-webkit-transform .3s ease-out; -o-transition:-o-transform .3s ease-out; transition:transform .3s ease-out; -webkit-transform:translate(0,-25%); -ms-transform:translate(0,-25%); -o-transform:translate(0,-25%); transform:translate(0,-25%) } .modal.in .modal-dialog{ -webkit-transform:translate(0,0); -ms-transform:translate(0,0); -o-transform:translate(0,0); transform:translate(0,0) } .modal-open .modal{ overflow-x:hidden; overflow-y:auto } .modal-dialog{ position:relative; width:auto; margin:10px } .modal-content{ position:relative; background-color:#fff; -webkit-background-clip:padding-box; background-clip:padding-box; border:1px solid #999; border:1px solid rgba(0,0,0,.2); border-radius:6px; outline:0; -webkit-box-shadow:0 3px 9px rgba(0,0,0,.5); box-shadow:0 3px 9px rgba(0,0,0,.5) } .modal-backdrop{ position:fixed; top:0; right:0; bottom:0; left:0; z-index:1040; background-color:#000 } .modal-backdrop.fade{ filter:alpha(opacity=0); opacity:0}.modal-backdrop.in{ filter:alpha(opacity=50); opacity:.5 } .modal-header{ padding:15px; border-bottom:1px solid #e5e5e5} .modal-header .close{ margin-top:-2px } .modal-title{ margin:0; line-height:1.42857143 } .modal-body{ position:relative; padding:15px } .modal-footer{ padding:15px; text-align:right; border-top:1px solid #e5e5e5 } .modal-footer .btn+.btn{ margin-bottom:0; margin-left:5px } .modal-footer .btn-group .btn+.btn{ ; top:-9999px; width:50px; height:50px; overflow:scroll}@media (min-width:768px){ .modal-dialog{ width:600px; margin: 30px auto } .modal-content{ -webkit-box-shadow:0 5px 15px rgba(0,0,0,.5); box-shadow:0 5px 15px rgba(0,0,0,.5) }.modal-sm{width:300px}}@media (min-width:992px){ .modal-lg{ width:900px } } </style> Thank you in advance
  13. Hi I am trying to keep a tooltip on the page even when the user scrolls What I had in mind is keeping the the tooltip in a static position on the screen so as the user scrolls the position would stay teh same but for this to happen the margins would need to dynamically change. Here is my CSS so far /* Tooltip container */ .tooltip { /* border-bottom: 0px dotted black; If you want dots under the hoverable text */ } /* Tooltip text */ .tooltip .tooltiptext { border-radius: 5px 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.1); -webkit-box-shadow: 5px 5px rgba(0, 0, 0, 0.1); -moz-box-shadow: 5px 5px rgba(0, 0, 0, 0.1); font-family:Arial, Helvetica, sans-serif; font-size:16px; position: absolute; left: 1em; top: 2em; z-index: 99; margin-left: 350px; width: 450px; margin-top:25px; visibility:hidden; background-color: rgba(0, 75, 133, 0.5); opacity:0.6; padding-left:15px;padding-bottom:15px;padding-right:15px } /* Tooltip arrow */ .tooltip .tooltiptext::after { content: ""; position: absolute; top: 100%; left: 50%; ; border-width: 5px; border-style: solid; border-color: #555 transparent transparent transparent; } /* Show the tooltip text when you mouse over the tooltip container */ .tooltip:hover .tooltiptext { visibility: visible; opacity: 0.8; } My html line is repeated for each category which I have 17 categories <a data-image-id="1" class="navigation <ul> <li> <a data-image-id="1" class="navigation tooltip" href="#"><h2 style="text-align:center;margin-top:5px">Category1</h2><span class="tooltiptext">Tooltip Text</span></a> </li> <li> <a data-image-id="2" class="navigation tooltip" href="#"><h2 style="text-align:center;margin-top:5px">Category2</h2><span class="tooltiptext">Tooltip Text</span></a> </li> --> </li> and I have javascript to handle images changing <script type="text/javascript"> //<![CDATA[ window.onload=function(){ (function() { var images = { "1": "images/hygiene1.png", "2": "images/hygiene1.png", "3": "images/change_room.png", "4": "images/foam.png", "5": "images/drains.png", "6": "images/factory.png", "7": "images/cleaning.png", "8": "images/consumable.png", "9": "images/lifting.png", "10": "images/deboning.png", "11": "images/smoking.png", "12": "images/deboning.png", "13": "images/water.png", "14": "images/a_z.png", "15": "images/csk.png", "16": "images/boyens.png", "17": "images/galactic.png" }; var navTv = document.getElementById('nav-tv'); var arr = document.getElementsByClassName('navigation'); for(var i=0; i<arr.length; i++) { arr[i].onmouseover = function(e) { var a = e.target; var imgId = a.getAttribute('data-image-id'); var imgSrc = images[imgId]; var style = ['background-image: url(', imgSrc, ');'].join(''); navTv.setAttribute('style', style); } } })(); }//]]> </script> Any help pointing me in the right direction so that I can code it will be appreciated
  14. Hi I am trying to write a script that changes the background based on a navigation hover and I have got that part right. What I would like to further do is when I move off the navigation bar it remembers the last image, if this makes sense. Here is my code so far <nav> <ul> <li> <a href="#">Home</a> <img src="pic2.jpg" alt=""> </li> <li> <a href="#">About</a> <img src="pic3.jpg" alt=""> </li> <li> <a href="#">Clients</a> <img src="pic4.jpg" alt=""> </li> <li> <a href="#">Work</a> <img src="pic5.jpg" alt=""> </li> <li> <a href="#">Contact</a> <img src="pic6.jpg" alt=""> </li> </ul> </nav> <img src="pic1.jpg" alt=""> </div> and the css .container { position: relative; overflow: hidden; margin: 100px auto; width: 800px; height: 500px; -webkit-box-shadow: 10px 10px 10px rgba(0,0,0,0.3); box-shadow: 10px 10px 10px rgba(0,0,0,0.3); } .container img { position: absolute; top: 0; left: 0; z-index: -60; } .container li img { position: absolute; top: 0; left: 800px; z-index: -50; -webkit-transition: all 1s ease; -moz-transition: all 1s ease; -o-transition: all 1s ease; -ms-transition: all 1s ease; transition: all 1s ease; } nav { width: 170px; height: 500px; background: #fff; } nav h1 { padding: 20px; color: #ccc; text-align: right; font: 25px Georgia, Times, serif; } ul { width: 800px; height: 500px; list-style: none; } li a { z-index: 1; display: block; padding-left: 20px; width: 150px; height: 30px; background: white; color: #444; text-decoration: none; font: 14px/30px Helvetica, Verdana, sans-serif; } li:nth-child(1) { padding-top: 50px; } li a:hover { background: #eee; } li a:hover + img { left: 0px; } I think I would need javascript in here somehow. I am a newbie at javascript so if someone can point me in teh right direction it would be much appreciated.
  15. Hi I am trying to do a foreach loop withing a mysqli query I had it working with mysql but am struggling doing it with mysqli here is my code so far $query = mysqli_query($conn,'SELECT * FROM cooking_classes WHERE class_id IN (' . foreach ($_SESSION['cart'] as $key => $value) { $query .= $key . ','; } $query = substr ($query, 0, -1) . ')'; $result = mysqli_query($query) or die(mysqli_error()); Thanks in advance Lional
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.