castajiz_2 35 Posting Whiz

I m new to javascript and I m little bit confused on how does a webpage read the actual script.
let's say I have the folowing code:
<script>

     vrijeme = document.getElementById("Label7").innerText;
     minute = vrijeme.substring(0, 2);
     sekunde = vrijeme.substring(3, vrijeme.length);
     alert("fuck you");

     var start_time=setInterval(secondFunction, 1000);

     function secondFunction()
     {
         sekunde = sekunde - 1;
         if (sekunde < 0)
         {
             minute = minute - 1;
             sekunde = 59;

         }
         if (minute <0)
         {
             clearInterval(start_time);
         }
         if (sekunde < 10) { document.getElementById("Label7").innerText = minute + ":0" + sekunde; }
         else { document.getElementById("Label7").innerText = minute + ":" + sekunde; }

         if (minute < 10 && minute < parseInt(vrijeme.substring(0,2))) { document.getElementById("Label7").innerText = "0"+minute + ":" + sekunde; }


     }

  </script>

and I add the function to my button onclick event ...
I noticed that as soon as I opened the browser the SCRIPT RAN! So i suppose the script runs automatically as the webpage opens?
The other question that is bothering is related to the above code. The setInterval function reffers to the actual function that is written. How does the browser see the public variables declared in the script since the setInterval() function just points to the written function but not the code that is above the function (the variables ect...). I hope I was clear enough.
It would be great if you can recommend an article about .js execution on a web page.

castajiz_2 35 Posting Whiz

Will try that tomorow tnx

castajiz_2 35 Posting Whiz

You could use the

ConsoleKeyInfo

class and the

ConsoleKey

struct. Put them in a do while loop and you should be able to manage your code with spaces after the number input. Don't forget to combine them with the Console.Read() or .ReadLine() methods...

castajiz_2 35 Posting Whiz

I ve seen your code, I can have a deeper look at it but in 4 days from now on. If you find the error than post it so that we actually know that youre done with it ...

castajiz_2 35 Posting Whiz

What is the best way to download the html content from another site and display it into my website? What is the best built in class to use for this case?

castajiz_2 35 Posting Whiz

I m sorry for the question. I found out that aplying a relative position attribute solves the problem. Now I m able to move the div tag accross my webform!

castajiz_2 35 Posting Whiz

Is there a easier way to move and postion the object from the toolbox in visual studio asp.net framework.When I say easier i reffer to windows forms framework object positiong where moving objects accross the form is a piece of cake.

castajiz_2 35 Posting Whiz

Ok, I ve been struggling for the last two weeks to get my webservice working on somee.com. I managed that. Then my database corrupted but managed to get it migrated it to mysql before that and everything' s fine. Now the final problem that I have and just can't solve is connecting from somee.com(asp.net hoster) to another server using mysql. In the cpanel i enabled a remote sql connection from somee.com. So i should access my database (actually my webservice on somee.com should access the database). However I m not able to do that this is the string that I have specified:

using (MySqlConnection con = new MySqlConnection("Server=89.201.163.108;Port=3306;Database=callofdu_energsun;Uid=callofdu_eses;Pwd=mypaswrod9999;"))

What do you think, should I change anything or is it maybe that somee.com doesnt' allow a external connection to the other servers altough the other server is enabled ( I configured it that way) to accept one.Bare in mind that I m using a free package at somee.com
One other thing. The Server ip address that I ve put and that you can see above is the SHARED IP ADDRESS.When i log on to php my admin it just says Server:localhost altough the database is uploaded on the server. Am I using the right ip address?
Im sorry for my spelling mistakes and a whole bunch of questions but I ve been trying to make this connection for the past 9 hours and I just can't achieve it.

castajiz_2 35 Posting Whiz

I would advice not to go to c or c++. I did that when I was at college. I picked a advanced c++ book and started learning some easy algorithms(I realised that i could have done that with c#). C# (Console Aplication) is where you should start and you ll find it pretty interesting believe me. Just go with c# for the time being and then switch to c or c++ or any other language, but I think you'll come back to c# when you see how Sweeter it is.
The point is that you should start SOLVING problems on your own no matter what language you pick. Once you get along with problem solving, then you can experiment with other languages and see what field interests you the most. When you choose your field see what is the best language to incorporate into that field.

castajiz_2 35 Posting Whiz
castajiz_2 35 Posting Whiz

This is a solution on how you could solve you problem, I m again working in java a little bit so I m trying to get the syntax to my brain so I hope that people won't get mad for posting the solution...

public class Solution
{

    public static void main(String[] args) 
    {
      Scanner sc=new Scanner(System.in);
        String concat="";
        String input = sc.nextLine();
        char [] array=input.toCharArray();
        for(int i =0;i<array.length;i++)
        {
            int z=(int)array[i];
            String binary=decToBin(z);
            concat=concat+CheckNumbersOfDigits(binary);
            concat+="-";

        }
       out.println(removeLastChar(concat));
    }
    private static String CheckNumbersOfDigits(String digit) 
    {

        int diglen=digit.length();
        int add_dig=8-diglen;
        for(int i=0;i<add_dig;i++)
        {
            digit="0"+digit;
        }
        return digit;
    }
    public static String decToBin(int dec) 
    {
        if (dec == 0) {
            return "0"; // special case
        }

        final StringBuilder result = new StringBuilder();
        int current = dec;

        while (current != 0) {
            result.append(current & 0x1);
            current = current >> 1;
        }

        return result.reverse().toString();
    }
    private static String removeLastChar(String str) {
        return str.substring(0,str.length()-1);
    }

 }
castajiz_2 35 Posting Whiz

My friend suggested me something else, he s got a good package at some popular hosting company.... I ll try to sort things out tomorrow and I ll give some feedback.

castajiz_2 35 Posting Whiz

Ok I hope that this is the problem(I ll pay them then but first I ll check it).My second question is, will somee.com free asp.net package allow me to make this external connection since it's a free package that I m using?

castajiz_2 35 Posting Whiz
  public string Data()  
        {
            string dohvat_podatka = "";


            using ( MySqlConnection con = new MySqlConnection("Server=xxx.000webhost.com;Port=3306;Database=xxx;Uid=xxx;password=xxx;"))
            {
                con.Open();
                using (MySqlCommand cmd = new MySqlCommand("SELECT ime FROM `nastavnik` WHERE prezime=@prezime", con))
                {
                    cmd.Parameters.Add(new MySqlParameter("prezime", "Carić"));

                    using (MySqlDataReader dr = cmd.ExecuteReader())
                    {
                        if (dr.HasRows)
                        {
                            while (dr.Read())
                            {
                                dohvat_podatka = dr.GetString(0);
                            }
                        }

                    }


                }

            }

            return dohvat_podatka;
        }

So what I m trying to do is to connect from my asp.net FREE HOST to a MySql FREE HOST. Is this connection possible? Of course I m getting a error due to the specified connection. I think that the problem is the free hosting that does not allow such a connection to their servers, what' s your opinion?
By the way I m having huge problems with mssql so i can't host on somee.com which would be the best way, but It would me take me like a week to do that.

castajiz_2 35 Posting Whiz

Tnx for the reply Ketsuekiame but in WP8 Framework a concatenation is generated everytime i create a method. I managed to sort that out by doing this:

  private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            ServiceReference1.WebServiceSoapClient client = new ServiceReference1.WebServiceSoapClient();
            client.HelloWorldCompleted += new EventHandler<ServiceReference1.HelloWorldCompletedEventArgs>(target);
            client.HelloWorldAsync(); //Last word concatenated Async!
        }

        private void target(object sender, ServiceReference1.HelloWorldCompletedEventArgs e)
        {
            TextBox1.Text = e.Result;
        }

After two days i finally managed to communicate with my webservice which is located on the folowing DNS:www.somee.com.
I made a reference in the WP8 solution but somehow i couldn't get the communication. I wasn't aware that I have to deploy the webservice on the server(-.-), so I basically converted the solutionfolder to a Application. That action made the communication possible.
The reason why I needed this webservice was to target my database as mentioned on the question. I successfully managed to insert some data into the database querying it with the WP8 emulator BUT am now failing at getting the data from the database.
Bassically I have my .asmx file where I stored all my methods which I then call by providing the code(almost as same as above) to display the results in my WP8 emulator(listbox,textbox,picturebox...).
Am I doing this right? and is this the way this should be done or should I use another approach?

castajiz_2 35 Posting Whiz

I ve built a simple webservice just for testing and whenever I implement it on my windows phone 8 solution(I add a refference) my methods which are decorated with the [webmethod] naturally seem to convert from type string for example to type void and at the end of the method name I see a async word. Can anyone please give me a suggestion how to fix that?
I need this webservice to target my database. I have to communicate with it via this webservice(actually using it as a proxy to get the the databaseserver). I doing everything locally. For example my webservice address is:
http://localhost:47852/Number.asmx?WSDL

castajiz_2 35 Posting Whiz

Watch videos 46, and 47, and you ll understand.
Click Here

castajiz_2 35 Posting Whiz

By all means you should reduce your code. After reducing it try to insert some data, see if the connection is right. If you manage to insert data into the database then you wont have a problem with inserting more data into it(for testing purpose).
The best thing for us would be to copy and paste your code to VS. and see where does the problem pop out, but with a lot of code here, it is a time consuming activity...

I see that you've got a Lot of columns in Only one table. That is not good. Try to make more Entities(Tables) and then to every each one of them assign related attributes(Columns). By doing that your are Normalizing your database (Google:database normalization).

castajiz_2 35 Posting Whiz

Does anyone here know what programming languages does the military usually use to make sumbarine softwares? If anyone can point to some links because i wasn't able to find anything on the net.

castajiz_2 35 Posting Whiz

Why dont you put your struct in the code so that others can directly copy and paste to VS...

castajiz_2 35 Posting Whiz

I ve done that but didn,t help...

castajiz_2 35 Posting Whiz

what framework are u using?

castajiz_2 35 Posting Whiz

I m getting the following error when trying to add a .mdf file and .log file to my account on somee.com
ERROR--> "You don't have the permission to open this file, contact the file owner or a administrator to obtain permission". I need to get my database on the server and that's the only way that i can achieve this(by providing a .mdf and .log file). My question is, is this a sql server managment studio installation problem(machine problem) or does the server have limitis since it's a free host?
I ve seen a youtube tutorial of someone providing this files and he managed to upload his files. Any suggestions would be great.

castajiz_2 35 Posting Whiz
listBox1.Items.Clear(); // for removing all items



   foreach(ListItem listItem in listBox1.Items) /* adding items to another listbox*/
    {
       if (listItem.Selected == True)
       {
          listBox2.Items.Add(listItem);
       }
    }
castajiz_2 35 Posting Whiz

Set your main form property IsMdiContainer to true

private void toolStripMenuItem_Click(object sender, EventArgs e)
        {

            Form f1 = new Form();
            f1.MdiParent = this;
            f1.Show();
        }

is this what you want?

castajiz_2 35 Posting Whiz

ok the first one was ridiculous(i miss understood it) but the last one was the problem.
1.)

UPDATE ovlasti INNER JOIN racuni ON racuni.username=ovlasti.username SET       izmjena = yes
WHERE racuni.ovlasti='admin';

5.)

SELECT TOP 10 PERCENT direktorij.direktorijID, direktorij.naziv, SUM(datoteka.velicina) AS velicina FROM datoteka INNER JOIN direktorij ON datoteka.direktorijID=direktorij.direktorijID

WHERE direktorij.direktorijID IN (SELECT direktorijID FROM direktorij WHERE direktorij.direktorijID NOT IN (SELECT nadDirektorijID FROM direktorij WHERE nadDirektorijID IS NOT NULL))

GROUP BY direktorij.direktorijID, direktorij.naziv ORDER BY SUM(datoteka.velicina) DESC;
castajiz_2 35 Posting Whiz

I have found it!
Click Here

castajiz_2 35 Posting Whiz

I can not believe my eyes, it is working!!! Thank you so much, I have spent nearly 11hours to somehow upload my C# code online but I just could not do it.

castajiz_2 35 Posting Whiz

ok, I ll try the FileZilla

castajiz_2 35 Posting Whiz

Hy guys, I managed to upload my winzip archive online and unzip it. However I can not access my website (I have the Default.aspx file which should be automatically recognized as the startup page, and lots of other files that go with the webapplication upload) however I get an error when trying to access that site. Is there a website which gives instructions on how to upload a asp.net file online and what do you think what am I doing wrong and what should I be aware of? I ve founded a free asp.net hoster (www.somee.com). This is the first time I m putting my asp.net files on the web itself previously I ve just used localhost to see the c# outcome.

castajiz_2 35 Posting Whiz

I' ve converted mssql database to mysql database (locally). I ve created a free subdomain and found a free webhoster on 000webhost.com. I m trying to import my mysql database onto the server using phpmyadmin interface but am unable to do this. I get the following error-->#1044 - Access denied for user 'a1581119_ts1'@'localhost' to database 'world'
I must say that i googled all day and found numerous answers but was not able to fix my issue. Any help would be greatly apreciated.

castajiz_2 35 Posting Whiz

have a look at this
Click Here
Click Here

castajiz_2 35 Posting Whiz
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication14
{
    public class Grades
    {
        public static void Main(string[] args)
        {
            int[][] grades;
            grades = new int[3][];
            grades[0] = new int[3];
            grades[1] = new int[2];
            grades[2] = new int[4];
            for (int i = 0; i < grades[0].Length; i++)
            {
                Console.WriteLine("Please input grade for first course followed by enter: ");
                grades[0][i] = Convert.ToInt32(Console.ReadLine());
            }
            Console.WriteLine();
            for (int i = 0; i < grades[1].Length; i++)
            {
                Console.WriteLine("Please input grade for second course followed by enter: ");
                grades[1][i] = Convert.ToInt32(Console.ReadLine());
            }
            for (int i = 0; i < grades[2].Length; i++)
            {
                Console.WriteLine("Please input grade for third course followed by enter: ");
                grades[2][i] = Convert.ToInt32(Console.ReadLine());
            }
            Console.Write("The grades for the first course are: {0}, {1}, and {2}", grades[0][0], grades[0][1], grades[0][2]);
            Console.WriteLine();
            Console.Write("The grades for the second course are: {0} and {1}", grades[1][0], grades[1][1]);
            Console.WriteLine();
            Console.Write("The grades for the third course are: {0}, {1}, {2}, and {3}", grades[2][0], grades[2][1], grades[2][2], grades[2][3]);
            Console.ReadKey();
        } // end Main
    } // end class Grades
}
castajiz_2 35 Posting Whiz

Well i don't know the exact definition of a bug altough i should know but if he doesn't consider that as a bug then it is not a bug...

@lithium112 --> try this code and your previous code and you will see the difference

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GunSimulation
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Press Spacebar to fire the gun. You start with 8 bullets in the mag.\n");
            int i = 8;
            while (true)
            {
                 ConsoleKeyInfo info = Console.ReadKey();
                if (info.Key == ConsoleKey.Spacebar)
                {
                    if (i > 0)
                    {
                        if (i <= 1)
                        {
                            Console.WriteLine("\nYou have 0 bullets in your pistol! Hit 'r' to reload!\n");
                            Console.WriteLine("All you hear is a click.\n");
                        }
                        else
                        {
                            i = i - 1;
                            Console.WriteLine("\nYou now have {0} bullets in your mag.\n", i);
                        }

                    }

                }

                if (info.Key == ConsoleKey.R)
                {
                    i = 8;
                    Console.WriteLine("\nYou now have 8 bullets in your mag.\n");
                }
            }
        }
    }
}
castajiz_2 35 Posting Whiz

Why isn't the Microsoft built in class Random class an type static class as the Math. class is.
Why didn't they make this class static?

castajiz_2 35 Posting Whiz

The problem is the mutliple readkey() method call, you have to have a storage for you readkey()...
try this

static void Main(string[] args)
        {
            Console.WriteLine("Press Spacebar to fire the gun. You start with 8 bullets in the mag.\n");
            int i = 8;
            while (true)

            {
                ConsoleKeyInfo info = Console.ReadKey();
                if (info.Key==ConsoleKey.Spacebar)
                {
                    i = i - 1;
                    Console.WriteLine("\nYou now have {0} bullets in the barrel.\n", i);
                }
                if (i == 0)
                {
                    Console.WriteLine("\nYou have 0 bullets in your pistol! Hit 'r' to reload!\n");
                    Console.WriteLine("All you hear is a click.\n");
                }
                if (info.Key == ConsoleKey.R)
                {
                    i = 8;
                    Console.WriteLine("You now have 8 bullets in your mag.");
                }
            }
        }
lithium112 commented: Great Solution +0
castajiz_2 35 Posting Whiz

Yea you're rigth. I just couldn't believe when searching the net that there are only several gps-c# related articles and another bad thing is that they are really outdated...

castajiz_2 35 Posting Whiz

If you need introduction to it(plain theory) I suggest to write on another section of daniweb...

castajiz_2 35 Posting Whiz

I ve been searching google for a long time now but I m not sure what kind of application (gps) should I develop. I would like from you guys to give me some trendy suggestions on what kind of gps app would be interesting to make and the most important thing is that I would like this app to differ from other gps apps.

castajiz_2 35 Posting Whiz

Post some code of your's...

castajiz_2 35 Posting Whiz
castajiz_2 35 Posting Whiz
castajiz_2 35 Posting Whiz

If i understood correctly you want your form covered with another panel? If so then just make a new location for panel2
for example:

panel2.Location = new Point(0, 0);

Adjust your coordinates.

castajiz_2 35 Posting Whiz

You've listed a lot of things what exactly is the main problem that s keeping you behind?

castajiz_2 35 Posting Whiz

Consider talking to your professor at school, he will definetly give you some ideas based on your knowledge... Your current knowledge is the most important thing. Don't get into something that may be too hard to solve. Of course, you can always try to make something big. Anyways you can always google what woud be good to do, what kind of app and on wich platform would be the best do develop it.

castajiz_2 35 Posting Whiz

You should post more code, your event is not defined as it is in VB

castajiz_2 35 Posting Whiz

-make two tables, first one(subjects or themes whatever this is called, for example geography, astronomy mathematics, medicine, physics... depending on your questions). Second one(questions, all sorts of questionS no matter the subject).

-make a realtionship 1:n
-well this is it concerning the database ( you could add some aditional stuff but I think this is enough.

-assuming that you have data inside now... proceeding with c#,sql...

-fill your combobox with the a sql statement,, example: SELECT Theme.Subject FROM THEME // once you read the statement you can easily use combobox.Items.Add(dr[0].ToString());

  • your combobox is filled with the themes/subjects(geography,maths...)

  • now when you click on a item let's say geography ,,, save that item as a string in a variable (store that in a variable when th selected_index_changed event fires.

-produce another sql statement for instance: SELECT QUESTION.name FROM QUESTION WHERE QUESTION.SubjectID=Theme.ID AND THEME.Subject=@selecteditem_of_combobox
-add your selecteditem, for MSSQL this would go like this:

 cmd.Parameters.Add(newSqlParameter("selecteditem_of_combobox",variable_value));

- Now inside your sql statement you could have used a random function but I' m not sure wich sql software are you using so I will leave that up to you.
- If you don't want to use the rand() function in sql you can always access the random c# class.
-once you read the question from your db I would store them in a list and then do something similar to this:

Random rnd= new Random();
int random_numb = rnd.Next(list.Count);
textbox1.Text=(string)list[random_numb];

then you would get a …

castajiz_2 35 Posting Whiz

What do you mean exactly when you say 'if the thext was an item' what else could it be in your case?

castajiz_2 35 Posting Whiz

Hmmm... I really don t know i m looking at the code and everything seems ok but maybe i missed something, anyways since your code is not long press f11 and go through every line and see what happens that is the only thing that i can say. Provide more information in your next post if possible and tomorrow if you don't solve the problem i ll rewrite your code a bit a post it here...

castajiz_2 35 Posting Whiz

Dont want to sound too smart here but it's the same as the output from the MessageBox.Show(string) you must have a string output otherwise you'll get an error ...

For your other part I would just go and convert each element to a string

 comboBox6.Items.AddRange(new int[]{1,2,3,4,5}.Select(x=>x.ToString()).ToArray());

Afters you could just convert these string to int's depending what you want to do with it...