0

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.

1

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

1

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();
    }
Votes + Comments
thanks for your answer. its solved now..
0

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

1

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);
}
1

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

1

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

2

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;

0

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);
      });
    }
  }
0

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.

0

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

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.

1

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