w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Beginner javascript
<!DOCTYPE html> <html> <head class="Header"> <title>JavaScript Test</title> <meta charset="UTF-8"> <style type="text/css"> .Body { font-family: sans-serif; color: blue; } </style> <script type="text/javascript"> window.onload = function() { message = document.createElement('P'); message.className = "Body"; message.innerHTML = "You Have Javascript!!"; document.body.appendChild(message); } </script> </head> <body> <p> <noscript> Your javascript is disabled </noscript> </p> </body> </html>

Categories : Javascript

I'm a javascript beginner and I can't get this code to run on the browser
you should first define your function, then use onload: function calculate(){ var x=document.getElementById("x"); if(x==5){ alert(x); } } window.onload = calculate;

Categories : Javascript

JavaScript Loop stuck beginner
sumSoFar is initialized to zero at the start of the function because the rest of the function uses the += operator which takes the current value of sumSoFar and adds a value to that and then assigns the new value back to sumSoFar. If it wasn't initialized to zero, then it would not have an initial value and the first += operation on it would not have the desired result. Initializing it to zero gives it the desired starting point so that the first time through the while loop, it adds currentNumber to that initial value of zero and assigns that to sumSoFar which is the desired behavior. FYI, you can see your function work here: http://jsfiddle.net/jfriend00/kXrV8/ and in the latest version, you can try different input arguments to your sum(n) function.

Categories : Javascript

beginner javascript; for loop with array of objects coming out as undefined
You're iterating one too far. for (var i = 0; i < family.length; i++) JavaScript arrays start at zero, and the last non-empty cell is at length - 1. Thus you have to stop iterating when your index is equal to the length, not when it's greater than the length.

Categories : Javascript

Beginner in JS and as3
picResponse and nameResponse are called asynchronously that means you are calling the playerData function when the picurl and playername are not set yet. You need to wait for both of those functions to complete before calling playerData. Something like : function fetchFBData (userId) { var picurl; var playername; FB.api('/'+userId+'/picture?width=50&height=50', picResponse); function picResponse (response) { picurl = response.data.url; FB.api('/'+userId, nameResponse); } function nameResponse (response) { playername = response.name; document.getElementById("demo1").playerData(playername, picurl); } }

Categories : Javascript

Servlets beginner
You get a 404 not found because simply the form points to an incorrect path. So it can not find the servlet to submit to. Your servlet class is "WelcomeServlet.java" in the package com.deitel.advjhtp1.servlets So in the HTML, the path should be: < form action = "com.deitel.advjhtp1.servlets.WelcomeServlet" method = "get">

Categories : Java

Beginner Python: Where to "while"?
per = 5 divbb = 69.46 divgr = 0.0527 tbondr = 0.0176 sp = 1430 total=0 pv=0 i = 1 while(abs(sp-total)) > 1: erp = i/10000. a = divbb b = divgr pv = 0 temppv = 0 print (sp-total, erp) for j in range(0, per): a=a * (1+b) temppv = a / pow((1+erp),j) pv=pv+temppv lastterm=(a*1+tbondr)/((erp-tbondr)*pow(1+erp,per)) total=(pv+lastterm) i += 1 should work. Obviously, there are a million ways to do this. But the general gist here is that the while loop will stop as soon as it meets the condition. You could also test every time in the for loop and include a break statement, but because you don't know when it will stop, I think a while loop is better in this case. Let me give you a quick rundown of two different ways you could

Categories : Python

How to use PFQuery in ios for beginner
Example: PFQuery *query = [PFQuery queryWithClassName:@"tempClass"]; [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) { if (!error) { // The find succeeded. The first 100 objects are available in objects } else { // Log details of the failure NSLog(@"Error: %@ %@", error, [error userInfo]); } }]; Good starter: Parse with TableView

Categories : Iphone

Beginner with 'nextLine'
You can read the line with the following statement: String line = in.nextLine(); Then, if you'd like to have the first word (for example), you can split the line and create a new Groucho object. String split = line.split(" "); Groucho g = new Groucho(split[0]); Here you can find more information about : Scanner String.split()

Categories : Java

Loops, beginner
I'm not going to give you the full solution, but here are the things you'll need to know to do it correctly and if you understand them, the problem becomes quite simple: If you have an integer k, you can convert it to a String with: String s = String.valueOf(k); This will allow you to more simply loop over the individual characters of the String, which represent the digits of the number. Then you can iterate over the characters one by one with char c = s.charAt(0); Where 0 can be a loop index variable that can loop from the first character (index 0) to the last (index s.length - 1 for String s) Then it becomes a matter of converting these back to an integer, which is straightforward, and then checking if they are even or odd. The standard way to do this is with a modulus. int k =

Categories : Java

Hibernate beginner
It seems that the problem is that the HQL editor doesn't get updated classes or metadata all the time when you make changes to the class or its metadata, it also seems that this can happen regardless of whether you use an external XML file or inline annotations. The only workaround I've found so far is to quit Netbeans and restart it. This makes the HQL query editor update, but is obviously quite annoying.

Categories : Java

Beginner: if else date
Instead of: if ($startup = $currentDate) { it should be if ($startup == $currentDate) { Moreover, instead of using $currentDate = echo date("Y"); try: $currentDate = date("Y");

Categories : PHP

QLocalServer - Help for beginner
Your problem is this (pun intended): QLocalServer* x = new QLocalServer(this); this is not valid outside non-static class member functions. main() is not a member function, and thus this doesn't exist. You can pass NULL pointer instead, to signify that the object shall have no parent: QLocalServer* x = new QLocalServer(NULL); Don't forget to add the network module in your project file's QT variable. For example: QT += OTHER_MODULES_YOU_USE_HERE network

Categories : C++

C# Beginner problems
dc.Print() wants a string argument and dc.GetEventsLogged() returns an int. You need to ToString() the int so that the types match. int numberOfEventsLogged = dc.GetEventsLogged(); string numberOfEventsLoggedAsString = numberOfEventsLogged.ToString(); dc.Print(numberOfEventsLoggedAsString)

Categories : C#

Beginner at sql, need aid with using GROUP BY
Put prodDown.LineNumber``andavailHrs.LineNumber` into the GROUP BY clause as well: GROUP BY prod.LineNumber,prodDown.LineNumber, availHrs.LineNumber All columns in the select list that have no aggregation like sum need to be in the GROUP BY clause.

Categories : SQL

Beginner CSS positioning (floating)
Change: #Content{ background:green; margin-right:280px; } to: #Content{ float: left; background:green; width:480px; }

Categories : CSS

beginner Cuda program
As Saviour Self pointed out in the comments - new means dynamic memory allocation on the heap at runtime. More information here. I think this is pretty much similar to the C-function atoi that converts a number stored as a char into a integer. In you case this should convert the number (stored as char) in argv[1] into a unsigned long int. Check it here. The language used in CUDA is called "C for CUDA" and as long as I've been reading and learning you can code in C but there are many features of C++ that are also supported. You can start taking a look at CUDA DOCUMENTATION. Hope this helps.

Categories : C

CSS Beginner troubles with hover
The element .two is found inside the .one element. so hovering .two means that you are also hovering .one. The event "bubbles" up to the parent element.. even if it doesn't look like that visually. To hover each one independently you will have to take .two out of .one. You might want to wrap both in a container to properly set their positioning. working jsFiddle <div class="someContainer"> <div class="one"></div> <div class="two"></div> </div>

Categories : CSS

Beginner with CSS style=border
border-left:10px solid blue; border-top:10px solid #ddd; border-bottom:10px dashed #ff0000; border-right:10px dotted #00ff00; Tutorial

Categories : CSS

Haskell beginner query
The spacing is misleading you. It looks like map( -> n x) is a function call, but the parentheses here are for grouping, not function call. map takes two arguments; the full call is map ( -> n x) fs, where ( -> n x) is the first argument (a lambda expression) and fs is the second. The lambda -> n x is a function that takes a function as an argument and returns the result of applying that function to x. n is the argument here. The type of -> n x is (a -> b) -> b (where a is the type of x). If you have learned about sections yet, the lambda is equivalent to the section ($ x). If you haven't, ignore that last sentence.

Categories : Haskell

Beginner: Do while loop issue
Your validOption() does not work correctly. The working of the rest of the loop is independent of that, but the termination depends on the correct return value. You check lower case characters there, but uppercase elsewhere. You change the checked character to uppercase just before the validity check. Change the characters to uppercase in validOption() too.

Categories : Java

directions for building a jsp as a beginner
first of all take a look at this http://www.apl.jhu.edu/~hall/java/Servlet-Tutorial/ A page written in jsp coul look as pretty as a html/css/js because actually the output of a jsp is actually html/css/js. You just control how to prints those elements using special tags. Write a page is a jsp is in my opinion as difficult as write it in asp.net, php or over technlogies. But there are some alternatives like rails that could make the thing easier. If you want to explore javascript only approaches then take a look at this http://coding.smashingmagazine.com/2012/07/27/journey-through-the-javascript-mvc-jungle/

Categories : Java

PHP loop pulling from SQL (beginner)
I suggest taking a look at the PHP manual http://www.php.net/manual/en/control-structures.intro.php http://www.php.net/manual/en/control-structures.while.php It is pretty straightforward once you get the hang of it and understand what it is supposed to be doing.

Categories : PHP

Beginner trouble do...while loop
To read a character/string from console, you could do the below (taken from here): try{ BufferedReader bufferRead = new BufferedReader(new InputStreamReader(System.in)); String s = bufferRead.readLine(); System.out.println(s); } Also the string can not be compared with == and != operators; use String's equals or equalsIgnoreCase. See here http://www.tutorialspoint.com/java/java_string_equalsignorecase.htm

Categories : Java

Java: Beginner using Scanner
Because you're checking only while (s.hasNextInt()) You could use try catch to catch the exception (see documentation here) you get when the program quits, so you can show your error message in the catch block without making the program close.

Categories : Java

AngularJS routing for beginner
As you can see the offical document, I think that you should use templateUrl instead of templateURL.

Categories : Javascript

Beginner's C++ program for a class
You wont' find anything before type your in console and sbustr should read from index 0 string name; int index; //index = name.find(' '); // comment out, name is empty, you won't find anything cin >> name; index = name.find(' '); // now you can find first space cout << "Middle Name: " << name.substr(0, index) << endl; // ^ Or just use std::stringstream #include <sstream> std::stringstream ss(name); std::string token; int i = 0; while(ss >> token) { switch(i) { case 0: std::cout << "First name: " << token << std::endl; break; case 1: std::cout << "Middle name: " << token << std::endl; break; case 2:

Categories : C++

pig beginner's example [unexpected error]
This error indicates that Pig is unable to connect to Hadoop to run the job. You say you have downloaded Hadoop -- have you installed it? If you have installed it, have you started it up according to its docs -- have you run the bin/start-all.sh script? Using -x local tells Pig to use the local filesystem instead of HDFS, but it still needs a running Hadoop instance to perform the execution. Before trying to run Pig, follow the Hadoop docs to get your local "cluster" set up and make sure your NameNode, DataNodes, etc. are up and running.

Categories : Hadoop

Beginner ILNumerics: install under VS2012
Two options: 1) Make sure, all binaries are accesible as intended: ILNumerics uses AnyCPU targets and chooses the platform dependend subfolder by adding the "bin32" / "bin64" directories to the PATH envoronment variable on startup. Possibly there is something failing on your machine? You can make sure by placing the correct binaries (depending on your platform) directly into the output path manually. 2) In case the error persists: mkl_custom.dll depends on some other dlls itself. One (libiomp5md.dll) is delivered with the ILNumerics nuget package. Others are expected to exist on your system: KERNEL32.DLL and MSVCR110.DLL. Make sure, you have these! If the kernel dll was missing -> call it a miracle and reinstall your system. If the msvcr110 is missing -> go here and install the "Visual C

Categories : C#

Beginner JQuery Custom Animation
Here you go: http://jsfiddle.net/DerekL/t4FUG/ Because after -prefix-animation, the CSS styles it applied will revert to its initial state; therefore, you need to manually set its style again. Long story short, add a CSS style rule to .card when CardFront is true. Add: .card.flyedOut{ transform: translateX(0%) rotateY(0deg) translateZ(0px); } And: setTimeout(function(){ $(".card").toggleClass("flyedOut"); }, 1000); to the click event.

Categories : Jquery

html beginner coding with notepad
I guess you just forgot to close <p> and also the span id is missing a quote This should work: <body> Dit is mijn eerste website. <p> Mijn naam is: <span id="naam"> Stijn Bastiaansen. </span> </p> <p> <span id="schuin"> Ik volg deze opleding aan het ICT-Lyceum van het Roc Tilburg. </span> </p> <p> <span id="centreren"> Tekst centreren </span> </p> <p align="right"> of rechts uitlijnen </p> <p>kan ik ook al.</p> </body>

Categories : HTML

Java Beginner Program Help (if, else issue)
Always use String#equals to compare Strings. == will compare if the references are equal which doesn't really work for comparing equal strings due to how they are stored. if (reverse.equals(word))

Categories : Java

Apex beginner - Email from a trigger
the first trouble into your code is that your trigger is not BULK read about it here bulk trigger #1 bulk trigger #2 the next trouble is that you don't send email with Messaging.sendEmail try the following: trigger Test1 on Contact (after update) { Messaging.reserveSingleEmailCapacity(trigger.size); List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>(); for (Contact c : trigger.new) { // walk through all records which is processed Contact old = trigger.oldMap.get(c.Id); // get old record from oldMap if (old.Email != c.Email ) { // check current email Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage(); email.setToAddresses(new String[] {c

Categories : Email

Python Socket/Interrupt for beginner
You could consider using sockets to communicate between the music player and server. The recv() call (typically used with TCP sockets) or recvfrom() call (typically used with UDP sockets) are blocking -- so they should provide a nice blocking context to your nothingIsRecvd case and would allow you to get rid of the "while True" loop. You can find examples on Python Library reference: http://docs.python.org/release/2.5.2/lib/socket-example.html

Categories : Python

Beginner to web design, need to know why style isn't being invoked
Try embedding your stylesheet into your html file on the head section <style TYPE="text/css"> <!-- p{ color:#00E5EE; } div p{ color:#CC0000; } *{ border:1px dashed #3A5FCD; } --> </style> If this works (which will work... ) then you will need to check the path of both your html and css files. Run your html on a browser and check the url. Then replace the template.html with stylesheet.css and see if your stylesheet shows up. If it doesn't that would be a filepath problem. Let us know how this went

Categories : HTML

a Python beginner's weird(ish) query
Actually, the second element of the range points to element after that element we would like to extract from the str. Imagine that as for (i = 0; i < 3; ++i) ... if I can express that such way :-)

Categories : Python

Website Scraping with Jsoup beginner
You can iterate all TD elements, here is working example: package my.test; import java.util.Iterator; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import org.jsoup.select.Elements; public class JsoupTest1 { public static void main(String[] args) { Document doc = Jsoup.parse("<table><tr class='eventTableRow'><td id='1' class='class1'>value1</td><td id='2' class='class2'>value2</td><td id='3' class='class3'>value3</td></tr></table>"); Elements row = doc.select(".eventTableRow td"); Iterator<Element> iterator = row.listIterator(); while(iterator.hasNext()) { Element element = iterator.next(); String id = element

Categories : Java

Beginner Python 3.3.2 - How do I use .replace() from a file?
You can use str.maketrans to transform a1 and a2 into a translation table, which can then be used with translate: translation_table = str.maketrans(a1, a2) swapped = input1.translate(translation_table)

Categories : File

HTML(5) layout/structure help - beginner
You can create a wrapper class, and but use it only where you need it. So, in your case it would go like this... Logo/Nav (wrapper class) Header Content (wrapper class) Footer (wide one) Footer (wrapper class) That way, although it might seem chopped out, you'll get the desired behaviour, those elements in wrapper having the 'normal' width, while the other go the full width, by default. See how that works here. This is essential (and also obligatory by SO): div {background: #eee; height: 50px;} div.wrapper {background: #ccc; width: 200px; margin: auto;} EDIT And since you want to keep your footer together, not in two separate parts (which makes perfect sense), you can do this, it works too: <div id="footer"> <div class="wrapper"></div> </div> And

Categories : HTML

flask-login alternative for beginner
From what i know, there are no popular alternatives to Flask-Login, except writing your own one. If you plan to do this, flask.session is highly relevant, as is a part of the tutorial. There's also Flask-Security, but that builds on top Flask-Login. I used neither of them.

Categories : Python



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.