AleMonteiro 238 Can I pick my title?

JavaScript is very dynamic, so you can use OOP in various ways. Take a look at a couple of examples:

// -------------------------
// Using Prototype
var MyPrototype = function () {
    // do something
};

MyPrototype.prototype.MyMethod1 = function() {
    return this.MyMethod2();
};

MyPrototype.prototype.MyMethod2 = function() {
    return "something";
};

// Usage
var myObj = new MyPrototype();
myObj.MyMethod2();

// -------------------------
// Using a object like an "static" class

var MyStaticObject = {

    MyMethod1: function() {

        return MyStaticObject.MyMethod2();

    },

    MyMethod2: function() {
        return "Something";
    }

};

// Usage
MyStaticObject.MyMethod1();

For futher understading, read those pages:
https://developer.mozilla.org/en-US/docs/JavaScript/Introduction_to_Object-Oriented_JavaScript

http://killdream.github.com/blog/2011/10/understanding-javascript-oop/

diafol commented: Nice post +14
AleMonteiro 238 Can I pick my title?

I'd say the best way to handle the address bar text is using Regular Expression.

Or if just want to check if it's a valid URI, use this: Uri.IsWellFormedUriString(YourURLString, UriKind.RelativeOrAbsolute)

AleMonteiro 238 Can I pick my title?

I think the most important aspect of your app is to have the list of the hospitals with their address. If you have it, building the app is quite simple.

For what plataform are you planning on develop?

AleMonteiro 238 Can I pick my title?

I think it could be something like this:

if(!empty($secondMenus)) {

    $backgroundColor = $idMenuParent == 2 ? 'blue' : 'gray';

                ?>

                <div id="secondary-menu-main">

                <div id="secondary-menu-items" style="background-color: <?php echo $backgroundColor; ?> ">              
                <?php
                foreach($secondMenus as $secondMenu) {
AleMonteiro 238 Can I pick my title?

I used and liked very much this JS chart API: http://www.highcharts.com/

Hope it helps.

AleMonteiro 238 Can I pick my title?

But what if the database is not on the same machine?

That's why it's always better to have the connection string in the app.config.

In my opnion, the best way to use connection string is:
On app.config:

<connectionStrings>
    <add name="machine-name" connectionString="your connection string" />
</connectionStrings>

And in the code:

string hostName = Environment.MachineName.ToLower();

string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings[ hostName ].ConnectionString;

This way multiple developers can use the same config file(in case you use SVN) and also the deploy connection string, without having to change it every time.

This works if the DB is on the same machine, on the network or even on the internet. With no need to re-compile.

This can be used on windows forms and also asp.net web applications.

AleMonteiro 238 Can I pick my title?

Hello,

I'd made it something like this:

function initializeSelect(selectId, divQuantityId){  

    var 
        select = document.getElementById(selectId), // gets the select element
        divQuantity = document.getElementById(divQuantityId);  // gets the div element

    for(var i = 0; i <=20; i++) { 
        // create the option
        var option = document.createElement('option');
        option.innerHTML = i;
        option.value = i;

        // append the option
        select.appendChild(addOption);
    }

    // sets the onChange event to the select
    select.onchange = function() {
        divQuantity.innerHTML = select.value; // display the selected value on the div
    };
}

And then use the function like this:

initializeSelect('product1', 'quantity1');
initializeSelect('product2', 'quantity2');
AleMonteiro 238 Can I pick my title?

Are you thinking that someone will write that code for you? Guess again.

AleMonteiro 238 Can I pick my title?

How did you implement the counter? Are you handling the IP?

AleMonteiro 238 Can I pick my title?

Sorry, but I don't really use VB. But the logic should be enough, shouldn't it?

AleMonteiro 238 Can I pick my title?

Boolean is true of false, right? So normally it's used exactly to get/set if a "thing" Can or Can't be done, if it Is or if it isn't and if it Has or Hasn't something.

Examples:
this.HasChildren
this.IsVisible
this.CanUpdate or this.IsUpdatable

ChrisHunter commented: great help +4
AleMonteiro 238 Can I pick my title?
AleMonteiro 238 Can I pick my title?

Use a select from the ps_product table to insert into ps_product_supplier. Something like this:

INSERT INTO ps_product_supplier 
(id_product_supplier, id_product, id_product_attribute, id_supplier, product_supplier_reference, product_supplier_price_te, id_currency)  

SELECT
    NULL, id_product, 0, id_supplier, supplier_reference,  wholesale_price , 3
FROM 
    ps_product
AleMonteiro 238 Can I pick my title?

There's no magic way to do it, but there's others ways like storing the values A,B,C in an array and loop for a match or using RegEx.

I'd use RegEx for a short code, something like this:

IF ( RegEx.Match(TextBox1.Text, "^[ABC]$").Success ) Then

End If

To use RegEx you need to import System.Text.RegularExpressions.

ImZick commented: Nice +2
AleMonteiro 238 Can I pick my title?

The best alternative is to create a function to hide/show rows, something like this:

function toggleRows(select, rows) {

    var display = select.selectedIndex == 1 ? '' : 'none';

    for(var i=0; i < rows.length; i++) {
        document.getElementById(rows[i]).style.display = display;
    }

};

And you should use as:

<select onchange="JavaScript: toggleRows(this, ['testing1', 'testing2', 'testing3']);">
AleMonteiro 238 Can I pick my title?

That's because you are executing the script before echoing the $data.

If you invert it may work:

<p style="margin-bottom: 50px;"></p>
<?php echo $data; ?>

<script type="text/javascript">
var url = "<?php echo $url; ?>";
var temp = getElementsByClassName('daniweb');
document.write(temp);
</script>

Or, the way I think is better, use the onload event of the window:

<script type="text/javascript">
window.onload = function() {
    var url = "<?php echo $url; ?>";
    var temp = getElementsByClassName('daniweb');
    document.write(temp);
};
</script>

<p style="margin-bottom: 50px;"></p>
<?php echo $data; ?>
AleMonteiro 238 Can I pick my title?

There are some steps that you can do to verify where the problem lies:

  1. Debug the JavaScript code with your browser to see if $("form#myForm").serialize() is returning what is expected.
  2. Use your browser network watcher to ensure that the data is being sent
  3. Debug your PHP code to ensure that the data is recieved

If the data is recieved in your PHP code then is just a matter of validating the data and inserting into the DB.

Good luck.

AleMonteiro 238 Can I pick my title?

If you really want to learn I suggest you code yourself thru with NotePad++, or any other developers editor.

Using DreamWeaver, or any other WYSIWYG editor, can be quite productive, but you won't learn about coding.

AleMonteiro 238 Can I pick my title?

I don't have much experience with VB, but I would try something like this:

Dts.Variables("User::ReNameFile").Value = Dts.Variables("User::fileName").Value.ToString() + DatePart(DateInterval.Month, Now).ToString() + DatePart(DateInterval.Year, Now).ToString() + ".csv"
AleMonteiro 238 Can I pick my title?

You're welcome.

Just so you know, you could do it all in the UI with JS, but I particularly don't like this because you'd be retrieving all the records from the DataBase, transfering all to the browser and then processing all the data in the UI. If it was few records, there is no problem, but if you're working with lots of records the performance would be very poor.

AleMonteiro 238 Can I pick my title?
AleMonteiro 238 Can I pick my title?

I found that intriging to make, so I made a little demo in the style of a jQuery plugin.

Take a look, it's pretty basic yet, but can turned into a plugin.

<!DOCTYPE html>
<html>
    <head>
        <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>

        <script>

            // Extends jQuery methods
            $(function($){
                $.fn.extend({
                    /*
                        Create 'bullets' for each children of the selector element. 
                        Tested only with one element, so it's recommended to use #ID

                        @param holder is container that the cloned objects will be appened to.
                        @param proportion it's a decimal between 0.1 and 0.9. This will affect in the size of the cloned objects.
                    */
                    makeBullets: function(holder, proportion) {

                        var 
                            // Destination Container
                            $holder = $(holder),
                            // Properties that will be resized by the proportion specified
                            properties =  ["width", "height", "top", "left"];

                        // Each div that will be copied and resized
                        $(this).children().each(function(){
                            var $t =$(this), $c = $t.clone(), i, val;

                            // Each property that will be resized
                            for(i=0, il=properties.length; i<il; i++) {
                                val = parseInt( $t.css(properties[i]).replace("px", "") );
                                $c.css(properties[i], Math.floor(val * proportion) + 'px'   );
                            }


                            $c
                            // Adds mouse over/out styles to the bullets
                            .hover(function() {
                                $(this).addClass("hover");
                            },function(){
                                $(this).removeClass("hover");
                            })
                            // Adds click function, uses closure to retain the orignal item reference
                            .click(function($originalItem){
                                    //$holder.children().removeClass("selected");
                                    $t.siblings().removeClass("selected");
                                    $t.addClass("selected");
                                });

                            $holder.append($c);
                        });

                    },


                });

            }(jQuery));


            // OnLoad
            $(function(){   
                // Creates the bullets with 0.2 of their original size and append them to #bullets
                $("#original").makeBullets("#bullets", 0.2);
            });
        </script>
    </head>

    <style type="text/css">
        div#original > div, #bullets > div {
            width: 200px;
            height: 200px;
            border: 2px solid black; …
AleMonteiro 238 Can I pick my title?

Try this:

<html>
<head>
  <script>
  function CheckDivisors()
  {
     var 
        number=parseInt(document.divfrm.num.value),
        d=1,
        divisors = [];
     do
     { 
        if(number%d==0)
        {       
            divisors.push(d);
        }       
      d++;
     }
     while(d<=number/2);

     document.getElementById("divDivisors").value = divisors.join(", ");
  }
  </script>
  </head>
 <body>
 <form name="divfrm">
 Enter a number: <input type="text" name="num">
 <br>
 Divisors: <input type="text" name="div" id="divDivisors">
 <br>
 <input type="button" value="Display Divisors" onClick="CheckDivisors()">
</form>
</body>
</html>
`

It's not wise to make DOM changes inside a loop. DOM manipulation is heavy, so it's better to put gather all that you want to show and then show it all at once.

AleMonteiro 238 Can I pick my title?

As far as I know, barcode scanner work as a keyboard. So it may be sending an Enter key that click the default submit button, as said by stbuchok.

I'd suggest you to remove any <button type="submit" /> and <button /> and try it again.
Ps.: Buttons without types are treated as submit type too.

AleMonteiro 238 Can I pick my title?

Maybe like this:

string keys[] = DataList1.DataKeys[e.Item.ItemIndex].ToString().split(',');
string productId = keys[0];
string customerId = keys[1];
kvprajapati commented: Helpful. +14
AleMonteiro 238 Can I pick my title?

No, <br/> is not the best option to vertical space. I suggest using margin and/or padding, depend on your needs.

AleMonteiro 238 Can I pick my title?

To achieve this kind of validation you need to do it with JavaScript. Because if you do it only with asp.net, the page will make a request to the server to validate each field.

I recommend that you use jQuery to achieve this functionality without too much headaches.

There's lots of jQuery Form Validation plugins out there, just google a bit that you'll see.

But it's not hard to code your own.

The logic is kind of simple: When a input value changes, validate it's content and if it's not valid, show the warning message.
Take care of hidding the warning message when the input became valid.
It's also nice to differ a empty required field from a invalid content.

AleMonteiro 238 Can I pick my title?

Yes, it's a good idea to have a style sheet only for IE in your case.

You can do it like this:

<!--[if IE]>
    <link rel="stylesheet" type="text/css" href="all-ie-only.css" />
<![endif]-->

Take a look at this site for more info: http://css-tricks.com/how-to-create-an-ie-only-stylesheet/

AleMonteiro 238 Can I pick my title?

To my knowlodge, when you don't specify the width to 100% (last case) the browser takes care to make the child 100% of it's parent, including border and padding.

When you do specify width 100% (second case) you are saying that only the width must have 100%, without border and padding. So in the end the width will be the 100% of the parent plus border and padding.

And I think those implementaions depend on the browser.

Check those links to futher understanding:
http://www.w3schools.com/css/css_boxmodel.asp

http://www.daniweb.com/web-development/web-design-html-and-css/threads/442058/how-can-i-stretch-my-nav-bar-to-fit-width-of-browser-wothout-scroll-bar

http://css-tricks.com/the-css-box-model/

Smeagel13 commented: Clear and to the point, thanks. +2
AleMonteiro 238 Can I pick my title?

Try chaning command.BeginExecuteNonQuery() to command.ExecuteNonQuery()

AleMonteiro 238 Can I pick my title?

So, if you have the var setted to true, you can ignore the window.click. And after ignoring the window.click, set the var to false, so that in the next click you can close it.

Doesn't that work? Any doubts in this implementation?

AleMonteiro 238 Can I pick my title?

max = end * last

AleMonteiro 238 Can I pick my title?

You must use the cancel option: http://api.jqueryui.com/draggable/#option-cancel

<div class="draggable">
    <span class="text">SomeText</span>
</div>

$(".draggable").draggable({
    cancel: '.text'
});
AleMonteiro 238 Can I pick my title?

Did you import System.Data.SqlTypes ?

AleMonteiro 238 Can I pick my title?

retVal.Value returns 0 or 1 to bit columns, so converting to bool works. However, retVal.SqlValue returns an SqlBoolean object, that can't be converted to a bool, but the SqlBoolean object has an Value property that is a bool.

So, both should work:

CBoll(retval.Value)
'And
CType(retval.SqlValue, 'SqlBoolean').Value

I don't know if the syntax are ok cause I don't code much in VB. But you'll get the idea.

AleMonteiro 238 Can I pick my title?

Your code doesn't make any sense. When the user click any part of the #menu (incluing itens and sub menu) it will open the submenu, and when the user hover the mouse (hover is an alias for mouse over and mouse out events) it will close.

I think that what you want is to open the submenu if the user clicks only the <li> or even only the <li> super hero. Is that right?

If so, try this:

<ul id="menu">
  <li>Change text</li>
  <li>
        <label>Super Hero</label>
        <ul id="submenu">
          <li>Color Theme</li>
        </ul>
    </li>
</ul>

I'm using <label> to hold the link because I only want to close the submenu if the user clicks the label, and not the submenu also.

$("#menu > li:has(ul) > label").click(function(){ // Add click handler to the #menu li's label that have an ul brother
        $(this).next("ul").slideToggle("slow"); // First click opens, second closes
    });

It will open the submenu only if Super Hero is clicked, and once it's clicked again it'll close.

AleMonteiro 238 Can I pick my title?

Assuming that row is actually an TR object, try this:

$.ajax({
    type: "POST",
    url: "delete_order.php",
    data: "id="+id,
    success: function(){
        row.fadeOut(1000, function(){ 
            row.remove();
        });
    }
});

And please, ident your code before posting. It helps us to help you.

AleMonteiro 238 Can I pick my title?

Let see if I can explain...

The form onSubmit expects True or False. True means that the form is to be submited, False means to cancel the submit.

onSubmit=validateForm(); return false; Is saying to the browser that when the onSubmit is called, it'll execute validateForm() and, despise the result, it will always return false.

onSubmit= return validateForm(); Is saying to the browser to execute the validateForm and return it's result.

I think it's more clear if you think all in JS:

// onsubmit=validateForm(); return false;
form.onsubmit = function() {
    validateForm();
    return false;
};

//onsubmit=return validateForm();
form.onsubmit = function() {
    return validateForm();  
};
adam.adamski.96155 commented: Thanks for the explanation :) +4
AleMonteiro 238 Can I pick my title?

I think the correct use would be: onsubmit="return validateForm(this);"

AleMonteiro 238 Can I pick my title?

Is not too much pretty, but it works:

<!doctype html>

<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>jQuery UI Sortable - Connect lists</title>
    <link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css" />
    <script src="http://code.jquery.com/jquery-1.8.2.js"></script>
    <script src="http://code.jquery.com/ui/1.9.1/jquery-ui.js"></script>
    <link rel="stylesheet" href="/resources/demos/style.css" />
    <style>
    #sortable1, #sortable2 { list-style-type: none; margin: 0; padding: 0 0 2.5em; float: left; margin-right: 10px; }
    #sortable1 li, #sortable2 li { margin: 0 5px 5px 5px; padding: 5px; font-size: 1.2em; width: 120px; }
    </style>
    <script>
    $(function() {

        $( "#sortable1, #sortable2" ).sortable({
            connectWith: ".connectedSortable",
            receive: function(evt, ui) { 
                if ( ui.item.parent().hasClass("acceptOnlyOne") ) { // if drop target only accept one item
                    if ( ui.item.parent().children().length > 1 ) { // check if it has more than one item
                        alert("You can drop only one item in here!"); // alert something
                        $("#sortable1").append( ui.item.detach() ); // detach the dropped item from the dropped target and append it to the previous container
                    }
                }
            }
        }).disableSelection();
    });
    </script>
</head>
<body>

<ul id="sortable1" class="connectedSortable">
    <li class="ui-state-default">Item 1</li>
    <li class="ui-state-default">Item 2</li>
    <li class="ui-state-default">Item 3</li>
    <li class="ui-state-default">Item 4</li>
    <li class="ui-state-default">Item 5</li>
</ul>

<ul id="sortable2" class="connectedSortable acceptOnlyOne" style="min-height: 30px; min-width: 100px; border: 1px solid black;">
</ul>


</body>
</html>
AleMonteiro 238 Can I pick my title?

I think i made it:

<html>
    <style>
#top_menu_wrapper
{
    border: 2px solid green;
    width:600px;
    height:100%;
    float:right;
    text-align:left;
    padding:50px;
}

#top_menu_wrapper ul
{
    list-style-type: none; /*remove bullets*/
    text-align: right;
}

#top_menu_wrapper li 
{ 
    display: -moz-inline-stack;
    display: inline-block;
    zoom: 1; /* for IE */
    *display: inline;  /* for IE 6 e 7 */
}

#top_menu_wrapper li a 
{   
    padding: 0 15px; 
} 

#search_bar input[type="text"] {
    background: url(../IMAGE/search-white.png)no-repeat 10px 5px #444;
    border: 0 none;
    font: bold 12px Arial,Helvetica,Sans-serif;
    color: #d7d7d7;
    width:150px;
    padding: 6px 15px 6px 35px;
    -webkit-border-radius: 20px;
    -moz-border-radius: 20px;
    border-radius: 20px;
    text-shadow: 0 2px 2px rgba(0, 0, 0, 0.3); 
    -webkit-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 3px rgba(0, 0, 0, 0.2) inset;
    -moz-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 3px rgba(0, 0, 0, 0.2) inset;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 3px rgba(0, 0, 0, 0.2) inset;
    -webkit-transition: all 0.7s ease 0s;
    -moz-transition: all 0.7s ease 0s;
    -o-transition: all 0.7s ease 0s;
    transition: all 0.7s ease 0s;

    }

#search_bar input[type="text"]:focus {
    background: url(../IMAGE/search-dark.png) no-repeat 10px 5px #fcfcfc;
    color: #6a6f75;
    width: 200px;
    -webkit-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(0, 0, 0, 0.9) inset;
    -moz-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(0, 0, 0, 0.9) inset;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(0, 0, 0, 0.9) inset;
    text-shadow: 0 2px 3px rgba(0, 0, 0, 0.1);
    }
    </style>

    <body>
        <div id = 'header_wrapper'>
            <div id = 'logo_wrapper'>
                <h1><a href='index.php'>ECOMMERCE SITE</a></h1> …
AleMonteiro 238 Can I pick my title?

Try this way:

<div id = 'top_menu_wrapper'>
    <form  id='search_bar' action='Config_FullStoreURLSearchResults.asp' method='get' name='SearchBoxForm'>
        <ul>
            <li><a href='#'>Log In</a></li>
            <li><a href='#'>Register</a></li>
            <li><a href='#'>About Us</a></li>
            <li><input type='text' name='Search' id='search_input' value='Search...'/></li>        
        </ul>
    </form>
</div>
AleMonteiro 238 Can I pick my title?

What do you mean? I didn't understand your problem.

A input adress is a text input: <input type="text" name="adress" id="txtAdress" />

What are you looking for?

AleMonteiro 238 Can I pick my title?

Using IFrame the interaction between the apps will be very limited, sepecially if they're loaded from different domains.

I'd certainly create it directly into the OS, the main reasons would be control, interaction and extensibility using prototype.

AleMonteiro 238 Can I pick my title?

This should do the trick:

"(class)([\s\t ]+)(\w*)([\s\t\r\n ]*?)({+)"

$1 = class word
$2 = space between 'class' and the class name
$3 = class name
$4 = space between the class name and the '{'
$5 = the first '{' after the class name
AleMonteiro 238 Can I pick my title?

Due to browser security AJAX request can only be made to the same domain. That this if you domain is mydomain.com you won't be able to make an AJAX request to google.com.

To do this kind of verification, you need to have a server-side script that will make the validation, and your interface will make an AJAX request to that script.

AleMonteiro 238 Can I pick my title?

You could use something like this:

var frame = document.getElementById("myIFrame"); // iFrame with the HTML
var div = document.getElementById("myDiv"); // div to show the HTML

div.innerText = frame.document.body.innerHTML; // Sets the Text of the div as the HTML of the frame.

Using innerText will not parse the HTML.

AleMonteiro 238 Can I pick my title?

It would be something like this:

$(function(){ // OnLoad
    $("#MyInputID").keyup(function(){ // Key Up Event
        var val = $(this).val(); // Get value from input
        $("#MyParagraphID").html(val); // Set p html
    });
});
AleMonteiro 238 Can I pick my title?

Try this to block space:

$("#nickname").keypress(function(evt){
            if ( evt.keyCode == 32 ) // space
            {
                return false;
            }
        });

Here's my whole test:

<head>
        <script type='text/javascript' src='http://code.jquery.com/jquery-1.4.4.min.js'></script>
        <script type="text/javascript">

            $(function(){

                $("#nickname").keypress(function(evt){
                    if ( evt.keyCode == 32 ) // space
                    {
                        return false;
                    }
                });

                $("#nickname").change(function(){
                    str = $(this).val();
                    $("#log").append("<br/>change: "+ str);
                });
            });

        </script>
    </head>

    <body>
        <input type="text" name="nickname" id="nickname" />
        <div id="log"></div>
    </body>
AleMonteiro 238 Can I pick my title?

Hi, I didn't understand anything about your problem.

Please be more specific and try to explain what you want and what the problem is.