AleMonteiro 238 Can I pick my title?

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

AleMonteiro 238 Can I pick my title?

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

AleMonteiro 238 Can I pick my title?

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();
    }
slowlearner2010 commented: thanks for your answer. its solved now.. +2
AleMonteiro 238 Can I pick my title?

Glad to know =)

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

AleMonteiro 238 Can I pick my title?

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);
}
AleMonteiro 238 Can I pick my title?

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

Cheers!

AleMonteiro 238 Can I pick my title?

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

AleMonteiro 238 Can I pick my title?

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 …

AleMonteiro 238 Can I pick my title?

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.

AleMonteiro 238 Can I pick my title?

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

AleMonteiro 238 Can I pick my title?

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/

AleMonteiro 238 Can I pick my title?

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

Pls, just mark the tread as solved =)

AleMonteiro 238 Can I pick my title?

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.

AleMonteiro 238 Can I pick my title?

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?

AleMonteiro 238 Can I pick my title?

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.

AleMonteiro 238 Can I pick my title?

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;

AleMonteiro 238 Can I pick my title?

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
AleMonteiro 238 Can I pick my title?

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

AleMonteiro 238 Can I pick my title?

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);
      });
    }
  }
AleMonteiro 238 Can I pick my title?

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.

AleMonteiro 238 Can I pick my title?

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.

AleMonteiro 238 Can I pick my title?

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

AleMonteiro 238 Can I pick my title?

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");
  }
});
AleMonteiro 238 Can I pick my title?

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.

AleMonteiro 238 Can I pick my title?

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
            }
        });
    });
AleMonteiro 238 Can I pick my title?

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.

AleMonteiro 238 Can I pick my title?

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):
http://www.webmaster.pt/76-menu-jquery-14624.html
http://www.freshdesignweb.com/css-drop-down-navigation-menu.html
http://www.jqueryrain.com/example/jquery-menu-example/

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 =)

AleMonteiro 238 Can I pick my title?

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
AleMonteiro 238 Can I pick my title?

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

AleMonteiro 238 Can I pick my title?

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.

AleMonteiro 238 Can I pick my title?

I'm glad to know that it worked =)

jQuery.sort(a, b) need us to define which one those come first.
And we'll decide who comes first based on our stored indexes at current_order

So return current_order[$(a).attr('id')] - current_order[$(b).attr('id')]; would be easier to read like this:

var aIndex = current_order[$(a).attr('id')];
var bIndex = current_order[$(b).attr('id')];

// if aIndex > bIndex => returns positive value (meaning that b comes first)
// if aIndex < bIndex => returns negative value (meaning that a comes first)
// if aIndex == bIndex => returns 0 (meaning that it doesn't matter)
 return aIndex - bIndex;
AleMonteiro 238 Can I pick my title?

Hi Manish.
You want to display only months that have events but you're not checking if the current month has events or not.

You could do something very simple, that'll just try another month if that one doesn't have an event, like this:

    $numEvents = 0;

    while( $numEvents == 0 ) {
       // generate an array with all dates with events
        $sql = "SELECT * FROM ".$SETTINGS["data_table"]." WHERE `event_date` LIKE '".$cYear."-".$cMonth."-%'";
        $sql_result = mysql_query ($sql, $connection ) or die ('request "Could not execute SQL query" '.$sql);

        $numEvents = mysql_num_rows($sql_result);

        if ( $numEvents == 0 ) {
            // Logic to search for the next month, like $cMonth = $cMonth + 1;
        }
    }

But the best solution would be to query the months before searching. I mean, find the next month in wich there's a event(without trying them all). Something like:

 "SELECT DISTINCT YEAR(`event_date`), MONTH(`event_date`) FROM ".$SETTINGS["data_table"]." WHERE YEAR(`event_date`) >= ".$cYear." AND MONTH(`event_date`) >= ".$cMonth." ";
AleMonteiro 238 Can I pick my title?

Hey, I think this should work for you:

// Store the Ids order
var current_order = {
    'set_1' : 0,
    'set_2' : 1
};
// If there's no previous order, create it with default values
if (JSON.parse(localStorage.getItem("sorted"))== " ")
{
    localStorage.setItem("sorted", JSON.stringify(current_order));
}

$(function(){
    // Get last saved order
    current_order = JSON.parse(localStorage.getItem("sorted"));
    console.log("returning"+current_order);

    // Sort container
    $( "#container" ).sortable({ cursor: "pointer", 
        placeholder: "highlight",

        update: function(event, ui){
            // When an element is sorted, update all the Indexes at current_order
            $(this).children('div.innercontainer').each(function() {
                current_order[$(this).attr("id")] = $(this).index();
            }).get();   
        }   
    });
    //Disable text selecion
    $( "#container" ).disableSelection()

    //Sort the divs based on the current_order
    $("div#container").append(
        $("div.innercontainer").sort(function(a, b) {
            var sorted = current_order[$(a).attr('id')] - current_order[$(b).attr('id')];
            //console.log(sorted);
            return sorted;
        })
    );
}); 

Obs.: Not tested ^^

piers commented: You have helped me on different things and provided the understanding that I needed in regards to the indexes and therefore helped me solve this. +3
AleMonteiro 238 Can I pick my title?

Ok, I got what you want. But let me say, you don't need to change Ids for this.
What you need is to store the Id and his order.

Take a look at this: http://jsfiddle.net/86nu1wkw/2/

It's simple but it does what you need. If you change the indexes on current_order you'll see that they are displayed correctly.

You'll just need to store that info and get it as you already do with localStorage.

AleMonteiro 238 Can I pick my title?

I didn't understand much of what you are trying to do.
You have two divs with Ids: set_1 and set_2.
So, do you want to change thoses Ids for what?

AleMonteiro 238 Can I pick my title?

I wouldn't suggest using external script references.
Just download the jquery file from jquery.com, put in the same folder and use like this:

<script type="text/javascript" src="jquery.1.x.js"></script>

And the jQuery functions used are very basic, I think this would work with 1.6 or higher.

AleMonteiro 238 Can I pick my title?

Use sessions to stored the logged in user.
When the users logs in you need to save that info(UserId for example) on the Session.
And in every page load you must check if the session is valid.
If there's no session it means that the user did not logged in, so you can redirect him to the login page.
Simple logic.

AleMonteiro 238 Can I pick my title?

Hi piers, the selector on your attempt to update the ids is not valid.
Try like this:

$('div.innercontainer')
        .attr('set_1', firstset);
        .attr('set_2', secondset); 
AleMonteiro 238 Can I pick my title?

You're welcome.
Just mark as solved when you make it work =)

AleMonteiro 238 Can I pick my title?

Anyway, I played a little with that fiddle and came up with this: http://jsfiddle.net/L4nqhudr/1/

Is that what you want?

AleMonteiro 238 Can I pick my title?

I didn't understand much of your problem... If the jsfiddle does what you want, you can just change it for update 'color' instead of 'background', it should work normally for words.

AleMonteiro 238 Can I pick my title?

Hi Rustatic. The .NET Framework doesn't allow you to do it directly, but you can add an 'Hook' using User32.dll.

Here are some resources that should walk you trought it:
http://support.microsoft.com/en-us/kb/319524
https://sim0n.wordpress.com/2009/03/28/vbnet-mouse-hook-class/

AleMonteiro 238 Can I pick my title?

I don't think you'd wanna all this trouble, but the only time I worked with chats I ended up creating an XMPP server with Asterisk(Open Source).

It already has those 'Sent, Recieved, Read' status for the messages.
And if you wish you can enable SIP accounts for audio and video calls.

If you got an XMPP server, there's plenty of JavaScript clients ready for use.

The bad side of this implementation, it's the hard work. The server setup is not hard, but it can be trick to enable some codecs for video and audio. And you'd probabbly have to integrate your site account manager with asterisk, I mean, when a new user is created on your site, you'll have to create an XMMP account for him at Asterisk.

Good luck =)

AleMonteiro 238 Can I pick my title?

Yeah... it's kinda hard to understand too... I didn't.
Can't you post your classes or at least the methods you're talking about?

AleMonteiro 238 Can I pick my title?

Oh, sorry, my bad. You have to set html to empty;

var html = '', i;
AleMonteiro 238 Can I pick my title?

It's quite simple:

// $el = jquery element to add the itens
// num = number of elements to add
// method = method used to add elements
var _add = function($el, num, method) {
    var 
        html // hold the html string
        , i // counter;

    // Adds the elements in the html string
    for(i=0;i<num;i++) {
        html += '<li></li>';
    }
    // Adds the html string to the jquery element
    $el[method].call($el, html);

    // it could be writen simpler as
    if ( method == 'append' ) {
        $el.append(html);
    }
    else if ( method == 'prepend' ) {
        $el.prepend(html);
    }

};  
AleMonteiro 238 Can I pick my title?

By elegant do you mean simpler? Less code? More didact? More Efficient?
Elegant code it's a very personal concept i think.
For me, elegant code it's a set of well structured and dynamic functionalities.
That's said, here's a more dynamic function.

var _add = function($el, num, method) {
    var html, i;
    for(i=0;i<num;i++) {
        html += '<li></li>';
    }

    $el[method].call($el, html);
};  

_add($('ul'), 5, 'prepend');
_add($('ul'), 5, 'append');
AleMonteiro 238 Can I pick my title?

toplisek, you have only to change '$' for jQuery, not anything that starts with '$'.
Let me exemplify.

// jQuery object
var jQuery = { ... };

// Sets $ as a reference of jQuery object
var $ = jQuery;

// Variables that start with '$' are usually to identify that it hold a jQuery object;
var $el = $("#myDiv");
var $div = jQuery("#myDiv");
var $str = 'this is not commum, because it's confuses the programmer, but works normally';
AleMonteiro 238 Can I pick my title?

I'm not sure I understood exatcly... do you wan't to save multiple identical forms at once?

If so, I suggest you use json formatting to transfer the data.

You should create an object within JS to hold all the data, something like this

var arr = [];

$("#add-child div").each(function(){
    arr.push({
        id = $(this).find("#parentid").val(),
        salut = $(this).find("#chsalute").val(),
        fname = $(this).find("#chfname").val(),
    .
    .
    .
    });
});

$.post("AddChildDetails.php", { children: arr },
    function(data) {
        alert("Child added!");
        $("#addchildD").hide();
    });

In PHP, you'd have to parse the JSON data to an array and then loop it to make the inserts.

$children = json_decode($_POST["children"], true);

foreach($item in $children)
{
    //do inserts with $item->id...
}

Obs.: In JS you shouldn't use ID to get the inputs, because they wouln't be unique. Use name instead, you can have multiples.

AleMonteiro 238 Can I pick my title?

Nice job man =)

Cheers!

Just mark as solved to finish it ^^