A simple replace should do it:

// removes duple spaces
$result = str_replace("  ", " ", $tags);
// removes space after comma
$result = str_replace(", ", ",", $result);

but yes, regular expression would be better I guess... something like (,[ \s]+) and replace with ","

sorry but not time to test the regex for u know, i'm in a hurry

Checkboxes values are only submited if they're checked, and text values are always submited even if blank.
So if you check only 5 boxes, the length of $_POST['checkbox1'] will be 5 but the length of $_POST['quantity'] will still be 10.

I suggest you to name each input text with the correspoding prodcode used on the checkbox, like name='quantity_".$row['prodcode']."' and then for each checked input you get it's text using $_POST["quantity_".$check[$i]].

It's a silly thing... you're reaching for the form with document.getElementById('myForm'), but your form doesn't have id="myForm".

Just add the id to your form or use document.forms['myForm'] to get it by it's name.


    function onSelectedOption(sel) {
    var frm = document.forms["myForm"];
        if ((sel.selectedIndex) == 3) {
            frm.action = "a.php";
            frm.action = "b.php"; 
        // I don't think you want to submit the form eah time the combobox is changed, or do you?
        // If you do, just remove the comments.
slowlearner2010 commented: thanks for your answer. its solved now.. +2

Glad to know =)

Just mark as solved please, you can open another thread if you need futher assistence.

Since you are using bootstrap you could use BootstrapDialog, quite easy...

Just call BootstrapDialog.show({
    title: 'You title here',
    message: $(images)

And to upload it you could use xhr itself

var xhr = new XMLHttpRequest(),
    url = 'upload_page.php';
if (xhr.upload) {

    // file received/failed
    xhr.onreadystatechange = function (e) {
        if (xhr.readyState == 4) {
            if ( xhr.status == 200 ) {
                // File uploadded
                var response = xhr.responseText;
            else {
                // Upload error

    xhr.open("POST", url, true);
    xhr.setRequestHeader("X-File-Name", file.name);
    xhr.setRequestHeader("X-File-Size", file.size);
    xhr.setRequestHeader("X-File-Type", file.type);

    xhr.setRequestHeader("Content-Type", "multipart/form-data");

You're welcome.
Just mark the thread as solved please. You can create a new one if you need futher assistence.


You can just take apart the URL page and the params, like this:

function LoadYearMakeModelUsingAutoVin(controlItem, dataSourceUrl, postParams) {

    var xmlHttp2 = new XMLHttpRequest();
    xmlHttp2.open("POST", dataSourceUrl, false);

    //Set proper header data
    http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    http.setRequestHeader("Content-length", postParams.length);
    http.setRequestHeader("Connection", "close");




//And use it like
LoadYearMakeModelUsingAutoVin(controlId, 'RequestXml.aspx', 'name=GetVehicleInfoUsingVinCanada&VinOrSerialNumber=' + vinOrserialnumber);

Or you could use FormData also:

I'm a little bit confused by what you're saying, but let me try to explain to you how it works:

When the browser request newspaper.com/sports, the WebServer (IIS or Apache or etc) will first see if there's any Rewrite Rules that match /sports.

If there's no rule that match /sports, then the WebServer will think that /sports is an directory (because there's no extension and the WebServer handle each requested file by it's extension, so it knows what and how to treat the file - extensions are related to MIME Type configs and Module Handlers).

If the directory /sports exists, then the WebServer will try to find the default document for that directory (index.html, default.aspx, index.php and etc). If the default document exists (default document configuration and also the physical default doc), then the WebServer will parse this file and return it's content.

If the directory /sports exists but there's no default document, then WebServer will either list the directory contents (if the WebServer is configured to do so) or it'll return the error 403 - 'Directory Listing not Permitted'

Last but not least, if the directory doesn't exists at all the WebServer will return 404 - 'Not Found'.

If you don't know them, rewrite rules make possible /sports to be redirect to /sports.html or even /sports/volley to /sports?id=volley.
Rewrite rules are very usefull. Most sites that have friendly urls use rewrite rules.

Anyway, to help you out you need to show us what 'code' are you seeing instead of ...

There's a quite simple "workarround" for this. Just put a div on the bottom to act like an "fader".

Take a look on a simple example: https://jsfiddle.net/alemonteiro/ffko2g45/1/

The background on the fader div could be just an rgba(255, 255, 255, 0.5), but I tought an actual gradient would look better.

Anyway, you can change the background to improve it's look.

Or you can just use the change listener instead of the click. When the change is fired the checkbox state has already been updated.

I agree that hiding the destination link it's not a good ideia, but anyway, here's a way you can count the clicks:


Glad to know that you work it out yourself, and it was pretty quickly! =)

Pls, just mark the tread as solved =)

About jQuery... if you don't, you should have a good base of knowlodge about JavaScript. If you undertand JS well, you'll take much more advantages of jQuery.
After that, one of the best ways to extend your knowlodge of it, it's to extend jQuery itself! Creating a well organized and reusable plugin is a good chalange that will give you lot's to research about.

Yes, you should use WebBrowser, and the post that clicks the button would help you, because you need to type the text and then click the button, right?

Hi darren, can you be a little more specific? What vars are undefined/null? What browser are you using?

Anyway, you should check if cssSheets, rules, and rule are defined.
I think that this function run on a page without CSS files, or with a file without rules would throw errors, but I did not test it.

You can do it by seaching rules inside the css sheets.
I took some time to play with this:

    <style type="text/css">
        body {
            background: "#F00";
            background-image: url(http:\\teste.png);
            color: #FFF;
            font-weight: bold;
        <script type="text/javascript">
        var seachHttp = function () {
            var cssSheets = document.styleSheets, // Loaded CSS Sheets
                i =0, il = cssSheets.length, // Counter and limit for sheets
                j, jl, rules, rule, // Counter and vars for Rules inside a Sheet
                stylesToSearch = [ // Properties to Seach HTTP ON
                k, kl=stylesToSearch.length, // Counter for properties
                s, // Current Property
                v // Current Value;

            for(;i<il;i++) { // Loop Sheets
                rules = cssSheets[i].rules || cssSheets[i].cssRules;
                for(j=0,jl=rules.length;j<jl;j++) { // Loop Rules
                    rule = rules[j];
                    for(k=0;k<kl;k++){ // Loop Styles
                        s = stylesToSearch[k]; 
                        v = rule.style[s]; // Get Value from Current Style
                        if (  v !== undefined && v.toString().toLowerCase().indexOf("http") > -1 ) { // Seach for HTTP Content
                            alert("Found HTTP at " + rule.selectorText + " " + s + " = " + rule.style[s]);


Notes: IE alerts two times(one for background and another for background-image); FF and GC alert only for background-image;

berserk, take a deep breathe and debug the code!
You need to understand where it fails so you can figure out how to fix it.
First of all, when you check a checkbox, does it trigger the change listener? Does it save in the cookies? Does it save correctly?

diafol commented: For the deep breath quote. Ha ha ha +15

Did you check the console for errors?
You need to have the references for jQuery and jQuery.cookie.

You're missing the call for repopulateCheckboxes();

Try like this:

// only code to be executed on page load goes inside here, functions are better left outside so it can be used for other pieces of code 
$(function() {
  var $checks = $("input:checkbox");
  $checks.on("change", function(){
    var checkboxValues = {}, allChecked = true;
          checkboxValues[this.id] = this.checked;
          allChecked = allChecked && (this.checked === true || this.checked === "checked" );
    $.cookie('checkboxValues', checkboxValues, { expires: 7, path: '/' })
    if ( allChecked ) {
      $('#chkSelectDeselectAll').attr("checked", "checked");
    else {
  $.cookie.json = true;

  function repopulateCheckboxes(){
    var checkboxValues = $.cookie('checkboxValues');
      Object.keys(checkboxValues).forEach(function(element) {
        var checked = checkboxValues[element];
        $("#" + element).prop('checked', checked);

In your page you should wrap that JS code inside a tag and only call it on the page load, like:

$(function() {

    // ...Code to be executed when the DOM has finished loading


You should also use Developer Console to see if any errors are ocurring, and debug the script if needed.

beserk, take a look at this fiddle: http://jsfiddle.net/aLhkoeed/6/
Your method is repopulateCheckboxes, but you're calling repoulateFormElements();

If you wanna do it with localStorage, take a look at this similar thread: https://www.daniweb.com/web-development/javascript-dhtml-ajax/threads/494426/keeping-sortable-order-on-refresh

About the reload question from Diafol, if you're using AJAX to send some data to the server, you should also use it to get some data. I mean, the response from your AJAX method could be the updated table so you can update the user interface without reloading.
Another way is to make another AJAX request when the first one is completed.

innerHTML will give you the HTML inside the node, if you want plain text use .innerText;

Hi beserk.

First detail: you're missing an ');' on the jQuery :checkbox change event listener.

Where do you call repopulateFormELements() ? On window load? It isn't explicit in your code.

And one more thing... why do you handle checkbox with jQuery and also with inline onClick?
I'd remove the checkOne function and would update the change listener to something like this:

var $checks = $(":checkbox");
$checks.on("change", function(){
  var checkboxValues = {}, allChecked = true;
        checkboxValues[this.id] = this.checked;
        allChecked = allChecked && (this.checked === true || this.checked === "checked" );
  $.cookie('checkboxValues', checkboxValues, { expires: 7, path: '/' })
  if ( allChecked ) {
    $('#chkSelectDeselectAll').attr("checked", "checked");
  else {

To check if a var is a number you should use

if ( Number(a) === a ) {
    // It's a number!
else {
    // It's not a number

Another detail, in you validateNumber function you may throw an error, but you are not handling that error when you call the validateNumber function.
You should put in a try{} catch{} and set the number 0 if there's an error.

The confirmation box is quite simple:


        if ( ! confirm('Are you sure you want to delete this?') ) {

        var btn_dlt = $(this); 
            type: "POST",
            url: "./delete-action.php", 
            data: { id: btn_dlt.attr("id") } 
        }).done(function( msg ) { 
            if(msg == "Success"){  
                $('#err_msg').html(msg);  err_msg field

If both databases are at the same server(MySQL Instance) you can just prefix the tables with the database name.

FROM database_1.calendar AS C LEFT JOIN database_2.history AS H

Make sure that the user logged in has permission to access both databases.

Hi Simon, I can't suggest you one specific cause I've never used one similar to what you want.
But I can say there's hundreds of jQuery Menu plugins that can be customized to do as you wish.

One of the most basics, that you would need to play with CSS to get the desired result is jQuery UI Menu. It's simple but quite powerful if you know you're way arround CSS and jQuery.

If you want something more "ready" to use, take a look at some compilations of jQuery menu plugins (there's lots out there):

I'm certain that the one you're looking for already exists.
Then, after you tried some, we can help you customize it if you need =)

Hi Yuki.

DataGridView.Columns is a collection that you can manipulate as you wish.

There's a couple ways of doing it, one way to just add one more columns is:

this.myDataGrid.Columns.Add(new DataGridTextColumn() {
    HeaderText = "My Column",
    Name = "My Column",
    DataPropertyName = "MyDataName"

Be aware that exists more than one type of DataGridViewColumn, see more here.

And are you developing Windows Forms on Visual Studio?

If you are, when you create something on with the VS UI, like adding columns to your grid, or a button, VS actually generates a file named 'YourFormName.Designer.cs'. In that file you can learn how VS creates all what you can see the on UI come true as code. It's a nice way to learn how to create programatically what VS gives you on the UI.

ddanbe commented: Good advice. +15

piers, this return value based on negative/positive values are only for the JavaScript Array.sort method, is not from jQuery itself.

And why does Array.sort works on a jQuery object? Well, because every jQuery object is actually a JavaScript Array. That's why you can always check if the jQuery object has elements using $(".myselector").length;

You can read more about the .sort function at: http://www.w3schools.com/jsref/jsref_sort.asp

You're welcome Manish, and hope that'll enjoy the forum.
If you don't have any more questions regarding this issue, you can mark as solved.