Jump to content

funstad

Members
  • Content Count

    36
  • Joined

  • Last visited

Community Reputation

0 Neutral

About funstad

  • Rank
    Newbie

Profile Information

  • Location
    Belgium

Previous Fields

  • Languages
    dutch, english
  1. Hello, I have this array print: Array ( [0] => Array ( [name] => color [value] => red ) [1] => Array ( [name] => color [value] => blue ) [2] => Array ( [name] => color [value] => green ) [3] => Array ( [name] => age [value] => 16 ) ) I want to receive this result: Array ( [color] => Array ( [name] => color [value] => red, blue, green ) [age] => Array ( [name] => age [value] => 16 ) ) it works using the following php code: foreach ($feature_names as $row) { if (!isset($result[$row["name"]])) { $result[$row["name"]]["name"] = $row["name"]; $result[$row["name"]]["value"] = $row["value"]; } else { $result[$row["name"]]["value"] .= ", " . $row["value"]; } } How ever in PHP 7.1 using the code $result[$row["name"]]["name"] = $row["name"]; generates an error. Does someone know a work around? Thanks in advance!
  2. funstad

    Javascript passing checkbox values to PHP

    I need the JavaScript part because i need to use a override controller on prestashop. I think my activeOnCats values are not send from JavaScript to PHP.
  3. funstad

    Javascript passing checkbox values to PHP

    hello, this is my javascript file: fcat = { initCatSelection: function () { $('#feature_form_submit_btn').on('click', fcat.overrideSubmit); $('.restoreButton > a').on({ mouseenter: fcat.switchRestore, mouseleave: fcat.switchRestore, click: fcat.restoreActiveCategories, }); fcat.selectActiveCategories(); }, selectActiveCategories: function () { var iniCat = $('#activeCategories').attr('initial_categories'); if (iniCat !== '' && iniCat !== null) { var catArr = iniCat.split(','); for (var a in catArr) $('input[type=checkbox][value="CAT'+catArr[a]+'"]').prop('checked',true); } }, overrideSubmit: function (e) { var cats = fcat.extractActives(); if (cats.length > 0) { cats.sort(); var str = cats.join(','); $('<input>').attr({ type: 'text', value: str, style: 'display: none', name: 'activeOnCats', }).insertAfter($('#activeCategories')); } else { alert('Error: You have to select atleast 1 category.'); e.preventDefault(); return false; } //Continue normal Submit }, extractActives: function () { var categs = []; $('input[name="option"]:checked').each(function() { if($(this).is(':checked')) categs.push(fcat.getCatID($(this).attr('value'))); }); return categs; }, getCatID: function (mix) { return parseInt(mix.replace('CAT', '')); }, switchRestore: function () { $('i', $(this)).toggleClass('icon-spin'); }, select: function (option, bool) { $(option)[0].selected = bool; }, unselect: function () { fcat.select(this, false); }, }; $(document).ready(fcat.initCatSelection); jQuery.fn.multiselect = function() { $(this).each(function() { var checkboxes = $(this).find("input:checkbox"); checkboxes.each(function() { var checkbox = $(this); if (checkbox.prop("checked")) checkbox.parent().addClass("aangeduid"); checkbox.click(function() { if (checkbox.prop("checked")) checkbox.parent().addClass("aangeduid"); else checkbox.parent().removeClass("aangeduid"); }); }); }); };
  4. Hello, I have created a java-script file which needs to see which check-boxes are checked and pass it to PHP Testing platform: Url: https://crezzur.com/test/backoffice/ Login: test@w3schools.com Pass: w3school When logged in go to the name " height " then next the "view" button click on the arrow and select "edit". there you will see a checkbox tree called "Available categories". So i need to find whats the issue for my JavaScript code not working. When you select a checkbox for example "Women" it should pass the variable to my php code when pressing on the save button. PHP code: if (Tools::isSubmit('activeOnCats')) { require_once(_PS_MODULE_DIR_.'featuresincategory/featuresincategory.php'); $fcat = new FeaturesInCategory(); $fcat->setFeatureCategories(Tools::getValue('activeOnCats'), Tools::getValue('id_feature')); } Anyone with some JavaScript knowledge could take a look at my issue?
  5. funstad

    Merge php array elements that have the same name

    Thanks for your explanation i am using the code below now and it does the job $result = []; foreach($not_distributed_feature_n_v as $v) { if(!isset($result[$v["name"]])) { $result[$v["name"]]["name"] = $v["name"]; $result[$v["name"]]["value"] = $v["value"]; } else { $result[$v["name"]]["value"] .= ", " . $v["value"]; } } $output[$this->l('Other Features')] = array_values($result); }
  6. how could i merge my array element so the print below results in the following output End result should be like this: [name] weight => heavy, less, diff [name] height => centimer Instead of: [name] weight => heavy [name] weight => less [name] weight => diff [name] height => centimer Current output: Array ( [Andere kenmerken] => Array ( [0] => Array ( [name] => weight [value] => heavy ) [1] => Array ( [name] => weight [value] => less ) [2] => Array ( [name] => weight [value] => diff ) [3] => Array ( [name] => weight [value] => less ) [4] => Array ( [name] => height [value] => centimer ) ) )
  7. funstad

    jquery get child atribute img src

    i have this right now (https://jsbin.com/lelaxam/edit?html,js,output) using the folowing code to display the image link $("#sim-edit-testtest .image").val($('img').attr("src")); The only issue now is that it takes the FIRST link it finds, how can i select the img src from the object i click on ?
  8. funstad

    jquery get child atribute img src

    Update: when you remove the <a> tag around the image it will show the image src, but i cant remove them for my project. any ideas?
  9. hello, i am working with jquery, thake a look at my jsbin code. when you click on the smile icon there popups a screen. Now the IMG field should be the IMG SRC. For some reason i cant get it to display the IMG SRC, any ideas?? https://jsbin.com/lelaxam/1/edit?js,output kind regards
  10. funstad

    Activate sql trough javascript after next sql

    What do you think about doing it this way? Note: that this is only accessible for administrators who are logged in. The reason it needs to happens trough a browser is because a non programmer needs to be able to create, save and send if fairly easy. JS: run code every x-time (60 sec in example) <script type="text/javascript"> setInterval(function(){ document.forms["myform"].submit(); }, 60000); </script> Html code: with hidden input to send to php "timerdone" <form method="post" name="myform"> <input type="hidden" name="timerdone"> </form> PHP code: see if the form is posted, and start query. (need to add a finish statement to stop the timer when all mails are send) if(isset($_POST['timerdone'])){ $msgtimer = 'Send: 50 mails send'; }
  11. Hey all, I have a question about PHP SQL trigger from javascript My situation: - I have Swift-mailer (program to send mails trough php) - I use this to send approx 1500 newsletters. - Every +/- 100 newsletters my screen turns white, i have to refresh and click the send button again to send the remaining newsletters. What i want to achieve: - after sending 50 mails the sql queries stop (this is done by using the SQL command "LIMIT 50") - I want then to let javascript kick in and wait for X time (example 5 min) - After the 5 min it needs to restart the sql query by an automated command (without clicking on the send button) Is this possible? or would you advise me to do this diffrent? Please note: It has to be send trough a browser.
  12. funstad

    Javascript attibute grabber

    mmmh i see, so this cannot be done this way, then i need to search further :/
  13. funstad

    Javascript attibute grabber

    the strange thing is when i only have a img element in the div it works for image, if i only have a element in the div it works for url but it only shows 1 when i enable both functions, does it search in the first element only ? maybe it need to be alterd so it search in the entire div tag and not in the first element after the div tag ?
  14. funstad

    Javascript attibute grabber

    $(function (){ // Resize function resize(){ $('.resize-height').height(window.innerHeight - 50); $('.resize-width').width(window.innerWidth - 250); //if(window.innerWidth<=1150){$('.resize-width').css('overflow','auto');} }$( window ).resize(function() {resize();});resize(); //Add Sections$("#newsletter-builder-area-center-frame-buttons-add").hover( function() { $("#newsletter-builder-area-center-frame-buttons-dropdown").fadeIn(200); }, function() { $("#newsletter-builder-area-center-frame-buttons-dropdown").fadeOut(200); });$("#newsletter-builder-area-center-frame-buttons-dropdown").hover( function() { $(".newsletter-builder-area-center-frame-buttons-content").fadeIn(200); }, function() { $(".newsletter-builder-area-center-frame-buttons-content").fadeOut(200); });$("#add-header").hover(function() { $(".newsletter-builder-area-center-frame-buttons-content-tab[data-type='header']").show(); $(".newsletter-builder-area-center-frame-buttons-content-tab[data-type='content']").hide(); $(".newsletter-builder-area-center-frame-buttons-content-tab[data-type='footer']").hide(); }); $("#add-content").hover(function() { $(".newsletter-builder-area-center-frame-buttons-content-tab[data-type='header']").hide(); $(".newsletter-builder-area-center-frame-buttons-content-tab[data-type='content']").show(); $(".newsletter-builder-area-center-frame-buttons-content-tab[data-type='footer']").hide(); }); $("#add-footer").hover(function() { $(".newsletter-builder-area-center-frame-buttons-content-tab[data-type='header']").hide(); $(".newsletter-builder-area-center-frame-buttons-content-tab[data-type='content']").hide(); $(".newsletter-builder-area-center-frame-buttons-content-tab[data-type='footer']").show(); }); $(".newsletter-builder-area-center-frame-buttons-content-tab").hover( function() { $(this).append('<div class="newsletter-builder-area-center-frame-buttons-content-tab-add"><i class="fa fa-plus"></i> Insert</div>'); $('.newsletter-builder-area-center-frame-buttons-content-tab-add').click(function() { $("#newsletter-builder-area-center-frame-content").prepend($("#newsletter-preloaded-rows .sim-row[data-id='"+$(this).parent().attr("data-id")+"']").clone()); hover_edit(); perform_delete(); $("#newsletter-builder-area-center-frame-buttons-dropdown").fadeOut(200); }) }, function() { $(this).children(".newsletter-builder-area-center-frame-buttons-content-tab-add").remove(); }); //Editfunction hover_edit(){$(".sim-row-edit").hover( function() { $(this).append('<div class="sim-row-edit-hover"><i class="fa fa-pencil" style="line-height:30px;"></i></div>'); $(".sim-row-edit-hover").click(function(e) {e.preventDefault()}) $(".sim-row-edit-hover i").click(function(e) { e.preventDefault(); big_parent = $(this).parent().parent(); //edit image if(big_parent.attr("data-type")=='image'){ $("#sim-edit-image .image").val(big_parent.children('img').attr("src")); $("#sim-edit-image").fadeIn(500); $("#sim-edit-image .sim-edit-box").slideDown(500); $("#sim-edit-image .sim-edit-box-buttons-save").click(function() { $(this).parent().parent().parent().fadeOut(500); $(this).parent().parent().slideUp(500); big_parent.children('img').attr("src",$("#sim-edit-image .image").val()); }); } //edit link if(big_parent.attr("data-type")=='link'){ $("#sim-edit-link .title").val(big_parent.text()); $("#sim-edit-link .url").val(big_parent.attr("href")); $("#sim-edit-link").fadeIn(500); $("#sim-edit-link .sim-edit-box").slideDown(500); $("#sim-edit-link .sim-edit-box-buttons-save").click(function() { $(this).parent().parent().parent().fadeOut(500); $(this).parent().parent().slideUp(500); big_parent.text($("#sim-edit-link .title").val()); big_parent.attr("href",$("#sim-edit-link .url").val()); }); } //edit linkonly if(big_parent.attr("data-type")=='linkonly'){ $("#sim-edit-linkonly .url").val(big_parent.children('a').attr("href")); $("#sim-edit-linkonly").fadeIn(500); $("#sim-edit-linkonly .sim-edit-box").slideDown(500); $("#sim-edit-linkonly .sim-edit-box-buttons-save").click(function() { $(this).parent().parent().parent().fadeOut(500); $(this).parent().parent().slideUp(500); big_parent.children('a').attr("href", $("#sim-edit-linkonly .url").val()); }); } //edit link & image if(big_parent.attr("data-type")=='imagelink'){ $("#sim-edit-imagelink .imagelink").val(big_parent.children('img').attr("src")); $("#sim-edit-imagelink .imageurl").val(big_parent.children('a').attr("href")); $("#sim-edit-imagelink").fadeIn(500); $("#sim-edit-imagelink .sim-edit-box").slideDown(500); $("#sim-edit-imagelink .sim-edit-box-buttons-save").click(function() { $(this).parent().parent().parent().fadeOut(500); $(this).parent().parent().slideUp(500); big_parent.children('img').attr("src", $("#sim-edit-imagelink .imagelink").val()); big_parent.children('a').attr("href", $("#sim-edit-imagelink .imageurl").val()); }); } //edit title if(big_parent.attr("data-type")=='title'){ $("#sim-edit-title .title").val(big_parent.text()); $("#sim-edit-title").fadeIn(500); $("#sim-edit-title .sim-edit-box").slideDown(500); $("#sim-edit-title .sim-edit-box-buttons-save").click(function() { $(this).parent().parent().parent().fadeOut(500); $(this).parent().parent().slideUp(500); big_parent.text($("#sim-edit-title .title").val()); }); } //edit text if(big_parent.attr("data-type")=='text'){ $("#sim-edit-text .text").val(big_parent.text()); $("#sim-edit-text").fadeIn(500); $("#sim-edit-text .sim-edit-box").slideDown(500); $("#sim-edit-text .sim-edit-box-buttons-save").click(function() { $(this).parent().parent().parent().fadeOut(500); $(this).parent().parent().slideUp(500); big_parent.text($("#sim-edit-text .text").val()); }); } //edit icon if(big_parent.attr("data-type")=='icon'){ $("#sim-edit-icon").fadeIn(500); $("#sim-edit-icon .sim-edit-box").slideDown(500); $("#sim-edit-icon i").click(function() { $(this).parent().parent().parent().parent().fadeOut(500); $(this).parent().parent().parent().slideUp(500); big_parent.children('i').attr('class',$(this).attr('class')); }); }// }); }, function() { $(this).children(".sim-row-edit-hover").remove(); });}hover_edit();//close edit$(".sim-edit-box-buttons-cancel").click(function() { $(this).parent().parent().parent().fadeOut(500); $(this).parent().parent().slideUp(500);}); //Drag & Drop$("#newsletter-builder-area-center-frame-content").sortable({ revert: true}); $(".sim-row").draggable({ connectToSortable: "#newsletter-builder-area-center-frame-content", //helper: "clone", revert: "invalid", handle: ".sim-row-move"});//Deletefunction add_delete(){ $(".sim-row").append('<div class="sim-row-delete"><i class="fa fa-times" ></i></div>'); }add_delete();function perform_delete(){$(".sim-row-delete").click(function() { $(this).parent().remove();});}perform_delete();//Bekijken $("#newsletter-builder-area-center-frame-buttons-exp").click(function(){ $("#newsletter-preloaded-export").html($("#newsletter-builder-area-center-frame-content").html()); $("#newsletter-preloaded-export .sim-row-delete").remove(); $("#newsletter-preloaded-export .sim-row").removeClass("ui-draggable"); $("#newsletter-preloaded-export .sim-row-edit").removeAttr("data-type"); $("#newsletter-preloaded-export .sim-row-edit").removeClass("sim-row-edit"); export_content = $("#newsletter-preloaded-export").html(); $("#export-textarea").val(export_content) $( "#export-form" ).submit(); $("#export-textarea").val(' '); });//Download $("#newsletter-builder-sidebar-buttons-abutton").click(function(){ $("#newsletter-preloaded-export").html($("#newsletter-builder-area-center-frame-content").html()); $("#newsletter-preloaded-export .sim-row-delete").remove(); $("#newsletter-preloaded-export .sim-row").removeClass("ui-draggable"); $("#newsletter-preloaded-export .sim-row-edit").removeAttr("data-type"); $("#newsletter-preloaded-export .sim-row-edit").removeClass("sim-row-edit"); export_content = $("#newsletter-preloaded-export").html(); $("#export-textarea").val(export_content) $( "#export-form" ).submit(); $("#export-textarea").val(' '); }); //Export $("#newsletter-builder-sidebar-buttons-bbutton").click(function(){ $("#sim-edit-export").fadeIn(500); $("#sim-edit-export .sim-edit-box").slideDown(500); $("#newsletter-preloaded-export").html($("#newsletter-builder-area-center-frame-content").html()); $("#newsletter-preloaded-export .sim-row-delete").remove(); $("#newsletter-preloaded-export .sim-row").removeClass("ui-draggable"); $("#newsletter-preloaded-export .sim-row-edit").removeAttr("data-type"); $("#newsletter-preloaded-export .sim-row-edit").removeClass("sim-row-edit"); preload_export_html = $("#newsletter-preloaded-export").html(); $.ajax({ url: "_css/news.css" }).done(function(data) { export_content = '<style>'+data+'</style><link href="http://fonts.googleapis.com/css?family=Source+Sans+Pro:200,300,400,600,700,900,200italic,300italic,400italic,600italic,700italic,900italic" rel="stylesheet" type="text/css"><link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css"><div id="sim-wrapper"><div id="sim-wrapper-newsletter">'+preload_export_html+'</div></div>'; $("#sim-edit-export .text").val(export_content); }); $("#newsletter-preloaded-export").html(' '); });}); This is the full code, line 119 is empty ?
  15. funstad

    Javascript attibute grabber

    Hey all i have following problem: I have a drag and drop editor which allow me to edit a URL, or allow me to edit a image trough a pop up screen. Now i want to change this so i edit the code of a image with URL (click able image). As you can see in the code below, everything works fine. Except it only shows 1 attribute So when i remove the <a></a> tags it shows the image url When i remove the <img></img tags it show the website url when i enable both only 1 shows up (website url) Anyone with a bit more javascript knowledge knows whats wrong ? Javascript: //edit link & image if(big_parent.attr("data-type")=='imagelink'){ $("#sim-edit-imagelink .imagelink").val(big_parent.children('img').attr("src")); $("#sim-edit-imagelink .imageurl").val(big_parent.children('a').attr("href")); $("#sim-edit-imagelink").fadeIn(500); $("#sim-edit-imagelink .sim-edit-box").slideDown(500); $("#sim-edit-imagelink .sim-edit-box-buttons-save").click(function() { $(this).parent().parent().parent().fadeOut(500); $(this).parent().parent().slideUp(500); big_parent.children('img').attr("src", $("#sim-edit-imagelink .imagelink").val()); big_parent.children('a').attr("href", $("#sim-edit-imagelink .imageurl").val()); }); html code <div class="sim-row-edit" data-type="imagelink" style="text-align:left"> <a href="http://google.be" target="_blank"> <img src="http://fietsendezwaluw.be/news/builder/img/layout1/img4.jpg" alt="" width="195" height="155" /> </a> </div> html code popup screen <div class="sim-edit" id="sim-edit-imagelink"><div class="sim-edit-box" style="height:330px;" ><div class="sim-edit-box-title">Edit image and url</div><div class="sim-edit-box-content"><div class="sim-edit-box-content-text">URL image:<span>(please use http://)</span></div><div class="sim-edit-box-content-field"><input type="text" class="sim-edit-box-content-field-input imagelink"/></div><div class="sim-edit-box-content-text">URL link:<span>(please use http://)</span></div><div class="sim-edit-box-content-field"><input type="text" class="sim-edit-box-content-field-input imageurl"/></div></div><div class="sim-edit-box-buttons"><div class="sim-edit-box-buttons-save">Save</div><div class="sim-edit-box-buttons-cancel">Cancel</div></div></div></div> Click here for the live example as you can notice when you press on a image it only show http://google.be and it doesn't show the image url.
×