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

But you're not checking for any text, you're just checking the checkbox value that will always be the same.

I'd go with something like this:

var checkedCount = 0,
    errMessage = undefined;

for (var i = 0; i < chks.length; i++) 
{         
    var chk = chks[i],
        // gets the checkbox value
        chkValue = chk.value, 
        // gets the text input related to that checkbox
        txt = document.getElementsByName('quantity_' + chkValue)[0],
        // gets the text input value
        txtValue = txt.value;

    if ( chk.checked === true || chk.checked === "checked" ) {
        checkedCount = checkedCount + 1;
        // Check if there's value on the text and if the text is not only blank spaces
        if (typeof txtValue !== 'string' || txtValue.toString().replace(/ /gi, "").length === 0 ) 
        { 
            errMessage = "You must fill all selected inputs";
            break;
        } 
    }
}

if ( checkedCount === 0 ) errMessage = "You must select at least one input";

if ( errMessage === undefined ) {
    return true;
}
alert(errMessage);
return false;

Obs.: Not tested.

And I think you shouldn't have re-open this thread. Since is another problem, in another language, you should have started a new thread.

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.

Example:

    function onSelectedOption(sel) {
    var frm = document.forms["myForm"];
        if ((sel.selectedIndex) == 3) {
            frm.action = "a.php";
        }
        else
        {
            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.
        //frm.submit();
    }
commented: thanks for your answer. its solved now.. +2

Hey fellas, I know it's been a while but only now I had the money and time to buy this box,
the best price/performance I could get (in Brazil) for my needs was this:

  • Motherboard Asus B85 Vanguard
  • Intel(R) Core(TM) i5-4460 CPU @ 3.20GHz
  • 16GB (2x 8 Kingston HyperX)
  • Font 600W Akasa 80 Bronze Plus
  • 1TB HD Seagate

I really didn't have money to buy all I wanted, but I realised I don't need it also. The 80GB SSD wouln't help much, so I decided to wait to buy a larger one latter.

This build for development is being great! Can't complain on anything.

And soon I expect to afford an Radeon R9 380 and an SSD to make it fly with games =)

Obs.: I changed my mind about nvidia because this motherboard only has support for Cross Fire.

Besides your inputs I also took a look at the builds on PC Master Race: https://www.reddit.com/r/PCMasterRace/wiki/builds

They have great info, I just couldn't build more likely because some vendors are really hard to find on Brazil, but with a little search replacements appear.

Thanks for the inputs and sorry for the late closeup ^^

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");
    xhr.send(file);
}

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

Cheers!

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");

    xmlHttp2.send(postParams);

    ...

}

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

Or you could use FormData also:
https://developer.mozilla.org/en-US/docs/Web/API/FormData/Using_FormData_Objects

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 ...

It's been a while, but just to register the solution:

Visual Studio 2008 didn't show, but there was two references on the .csproj file and that's what caused the problem, editing the file and removing the second reference was the only solution.

Thanks for all that helped.

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.

Just so you know:

$('#value') // jquery object
//set value as
$('#value').val(1);

$('#value')[0] // DOM object
// so you can also set the value as
$('#value')[0].value = "1"; // This is not recommended, it's just to show that jQuery objects relay on the DOM object itself

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:

https://jsfiddle.net/alemonteiro/5pqb8dz3/1/

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:

<html>
    <style type="text/css">
        body {
            background: "#F00";
            background-image: url(http:\\teste.png);
            color: #FFF;
            font-weight: bold;
        }
    </style>
    <body>
        <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
                    'background',
                    'background-image',
                ],
                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]);
                        }   
                    }
                }
            }
        }

        seachHttp();
        </script>
    </body>
</html>

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

I really didn't understand how you got it to work, but I'm glad you did =)

commented: thank you for the support :) +2

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?

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;
    $checks.each(function(){
          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 {
      $('#chkSelectDeselectAll').removeAttr("checked");
    }
  });
  $.cookie.json = true;
  repopulateCheckboxes();
});

  function repopulateCheckboxes(){
    var checkboxValues = $.cookie('checkboxValues');
    if(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 <script> 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;
  $checks.each(function(){
        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 {
    $('#chkSelectDeselectAll').removeAttr("checked");
  }
});

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:

$(".btn_dlt").click(function(){

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

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