Jump to content

Nathan

Administrators
  • Posts

    2,187
  • Joined

  • Last visited

  • Days Won

    75

Community Answers

  1. Nathan's post in Active Nav Options was marked as the answer   
    Fixed by adding this js snippet right before the closing </body> tag.
    <script> $(function() { $(".navbar-nav li").click(function(){ $(".navbar-nav li").removeClass("active") $(this).addClass("active") }) }) </script>
  2. Nathan's post in Modify Page Jump to Scroll was marked as the answer   
    Completed with this tutorial.
    http://alijafarian.com/responsive-page-scrolling-with-jquery-and-bootstrap/
  3. Nathan's post in Linking to Tabs was marked as the answer   
    Fixed by adding this just before the closing </body> tag.
    <script> $(function() { hashtag=window.location.hash if(hashtag!=""){ $('.nav-tabs a[href='+hashtag+']').tab('show') } }) </script>
  4. Nathan's post in Bootstrap Datepicker was marked as the answer   
    I was loading the .js files in the wrong order. Modified to:
    1. jquery
    2. moment.js
    3. bootstrap.min.js
    4. datetimepicker.
  5. Nathan's post in Hover Content in Bootstrap was marked as the answer   
    Ended up resolving with this 3rd party code I found on bootply.com
     
    http://www.bootply.com/TA3rS5mXd1
  6. Nathan's post in Form Validation was marked as the answer   
    Had to add a onsubmit check.
    function validate() { if (document.getElementById('delete').innerText != 'delete') { alert("you didn't enter the word delete"); return false; } return true; }
  7. Nathan's post in HTML Form Check Box & jQuery was marked as the answer   
    Fixed by adding this piece of jquery:
    $('.checkbox input').on('change', function(){ $(this).val($(this).prop('checked') ? '1' : '0'); } );
  8. Nathan's post in Standalone Image onClick YouTube Video was marked as the answer   
    Fixed with the following:
    <img id="high_res_image" src="high_res_image.jpg"> <div id="youtube_video" style="display:none;"> <!-- Put YouTube Video code here --> </div> This will show the image and hide the YouTube video. Then, in jQuery you'll need the following:
    $( "#high_res_image" ).click(function() { $( "#youtube_video" ).show( "slow" ); $( "#high_res_image" ).hide( "slow" ); }); What this will do is hide the high resolution image, show the YouTube div and then add autoplay=1 to the YouTube video iframe to (hopefully) start autoplay. Haven't tested it, but I think it should work in theory.
  9. Nathan's post in Ajax/Function Issue was marked as the answer   
    <!--Task jQuery/Ajax Call-->
    <script>
    function markcomplete(taskid,projectid)
    {
    $.ajax({
    url : 'scripts/submit.php', // give complete url here
    type : 'post',
    data : { taskid : taskid, projectid : projectid, submittype : 7},
    success: function (data) {
    // returns from server on success
    console.log(data);
    },
    failure: function (error) {
    // returns here on error
    console.log(data);
    }
    });
    }
    </script>
  10. Nathan's post in jQuery Help was marked as the answer   
    <script type="text/javascript">
    function check() {
    var element1 = document.getElementsByName("quantity11");
    var element2 = document.getElementsByName("quantity12");
    var element3 = document.getElementsByName("quantityreg");

    for (var i=0; i<element1.length; i++) {

    var nmbr1 = parseInt(element1[i].value,10);
    var nmbr2 = parseInt(element2[i].value,10);
    var nmbr3 = parseInt(element3[i].value,10);
    var nmbr = nmbr1 + nmbr2 + nmbr3;
    if (nmbr < 1){
    alert("Please add at least 1 treat pack to your order to proceed.");
    return false;
    }
    }

    return true;
    }
    </script>
  11. Nathan's post in How to remove a certain onClick event and add another was marked as the answer   
    Here we go.
     
    PHP/HTML:
    <li id="task'.$tasks['id'].'" class="open" data-taskid="'.$tasks['id'].'" data-projectid="'.$projectid.'"> Script:
    <script type="text/javascript"> function toggleFunction(taskid, projectid, submittype) { $.ajax({ url : 'submit.php', // give complete url here type : 'post', data : { taskid : taskid, projectid : projectid, submittype : submittype}, success: function (data) { // returns from server on success console.log(data); // below jQuery statement will toggle between 2 classes - open & closed $('#task'+taskid).toggleClass('open closed'); }, failure: function (error) { // returns here on error console.log(data); } }); } $(document).ready(function(e){ $('li[id^=task]').click(function(e){ var taskid = $(this).data("taskid"); var projectid = $(this).data("projectid"); if ($(this).hasClass('open')) submittype = 7; else submittype = 8; toggleFunction(taskid, projectid, submittype); }); }); </script>
  12. Nathan's post in Appending Date/Time to File Upload was marked as the answer   
    Found this as a fix:
    <?php // Split the original filename by the period character $pieces = explode(".",$_FILES["file"]["tmp_name"]); // Grab the last piece, which should be "jpg" $extension = array_pop($pieces); // Put the remaining pieces back together with the dot character, add the date, and then add a dot and the extension to get the new filename. $newfilename = implode(".",$pieces).date("Y-m-d H:i:s").".".$extension; // Move the file move_uploaded_file($_FILES["file"]["tmp_name"], "uploads/".$orgid."/".$newfilename); ?>
  13. Nathan's post in Copy Shipping Address to Billing if Checked was marked as the answer   
    Turned out wasn't too hard to fix, just a quick javascript snippet added to the footer. 
    $("#shiptobilling-checkbox").change(function(){ if($(this).is(":checked")){ $("[id^='shipping_']").each(function(){ data=$(this).attr("id") tmpID = data.split('shipping_'); $(this).val($("#billing_"+tmpID[1]).val()) }) }else{ $("[id^='shipping_']").each(function(){ $(this).val("") }) } })
  14. Nathan's post in textarea value was marked as the answer   
    Aha!
     
    Looks like it called "default" whether that's html or the WordPress I'm unsure, but it's working now.
    $giftmsg = $_SESSION['giftmsg']; $this->checkout_fields['order'] = array( 'order_comments' => array( 'type' => 'textarea', 'class' => array('notes'), 'label' => __( 'Order Notes', 'woocommerce' ), 'placeholder' => _x('Notes about your order, e.g. special notes for delivery.', 'placeholder', 'woocommerce'), 'default' => $giftmsg ) ); $this->checkout_fields = apply_filters( 'woocommerce_checkout_fields', $this->checkout_fields ); do_action( 'woocommerce_checkout_init', $this );
  15. Nathan's post in Echo Javascript Variable was marked as the answer   
    Figured out by popping it into a dialog box.
     
    alert(qtycheck); The issue was the variable was not being populated, easy to see once I had it to see.
  16. Nathan's post in Javascript Filter on Variable Set was marked as the answer   
    Here is the finished solution.
    function check() { var elements = document.getElementsByName("quantity"); var qtycheck = document.getElementById("qtycheck").value; for (var i=0; i<elements.length; i++) { if (elements[i].id != "quantity2442" && elements[i].id != "quantity2443") { var nmbr = parseInt(elements[i].value,10); if (nmbr > 100){ alert("You've selected more treats than your package allows." + nmbr); return false; } else if (nmbr > qtycheck){ alert("You've selected more treats than your package allows." + nmbr); return false; } } } return true; } Important notice: you will have to add the parseInt to
    var nmbr = parseInt(elements[i].value,10);
×
×
  • Create New...