|
You have several steps you need to do. Where exactly are you stuck?
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
Hey guys,
I need assistance with 2 blocks of code that I am getting error. Here they are:
var gameReport = "<h1>" + itemTitle + "</h1>" +
"<h2>By:" + itemManufacturer + "</h2>" +
"<img src="hg_id.png" alt="id" id=" + gameImg + " />" +
"<table>"
"<tr><th>Product ID</th><td>" + itemID + "</td></tr>" +
"<tr><th>List Price</th><td>" + itemPrice + "</td></tr>" +
"<tr>Platform</th><td>" + itemPlatform + "</td></tr>" +
"<tr><th>ESRB Rating</th><td>" + itemESRB + "</td></tr>" +
"<tr><th>Condition</th><td>" + itemCondition + "</td></tr>" +
"<tr><th>Release</th><td>" + itemRelease + "</td></tr>" +
"</table>" +
itemSummary;
And this:
for (var i = 0; i < 3; i++) {
ratingReport += "<div class="review"><h1>" + ratingTitles + "</h1><table><tr><th>By</th><td>" + ratingAuthors + "</td></tr><tr><th>Review Date</th><td>" +ratingDate+ "</td></tr>""<tr><th>Rating</th><td>";
for (var i = 1; i < ratingsAvg.length; i++) {
ratingReport += "<img src="hg_star.png" />";
}
ratingReport += "</td></tr</table>" + ratingSummaries + "</div>";
}
Thanks for any help
|
|
|
|
|
The syntax highlighting should have given you a clue - you need to escape quotes inside the string or use single quotes as well as double quotes.
var escaped = "<img src=\"an_image.png\">";
var single_quotes = '<img src="another_image.png">';
You should also check that you have your "+" symbols everywhere you need them - there is one missing after the opening <table> element.
|
|
|
|
|
"<img src="hg_id.png" alt="id" id=" + gameImg + " />" +
IF you are using for loop id need to unique value
|
|
|
|
|
Hallo!
I have a textbox , (made with Zendform), and y load the results of an array in this textbox with the autocomplete();
function , this was performing as expected a few days ago, but today the result is disgusting..the results appear by the textbox this way:
.Galicia
.Asturias
.[...]
this function its asociated with a"keyup" event...please any idea of what could be wrong??, I executed in Chrome, and the compilator, shows no errors... thanks!!
so let´s go to the code
$(document).ready(function(){
var comunidades=[
"Galicia",
"Asturias",
"Cantabria",
"Islas Baleares"
];
<pre> $("#comu").keyup(function(){
$(this).autocomplete({
source:comunidades
});
});
</pre>
<pre>
<label>Comunidad</label>
<?php
$fComu=$formNewClienteHotel->get("comunidad");
echo $this->formInput($fComu);
?>
</pre>
This is the class where the Form is declared:
<?php
namespace Alta\Form;
use Zend\Form\Form;
use Zend\Form\Factory;
use Zend\Form\Element;
class FormNewClienteHotel extends Form
{
public function __construct($name=null) {
parent::__construct($name);
$this->setAttributes(array(
'action'=>'',
'method'=>'post'
));
$this->add(array(
'name'=>'comunidad',
'attributes'=>array(
'type'=>'text',
'required'=>'required',
'id'=>'comu',
)
));
|
|
|
|
|
Calling autocomplete on every key press will most likely cause problems. You would normally only call the autocomplete function once:
$(function(){
var comunidades = [
"Galicia",
"Asturias",
"Cantabria",
"Islas Baleares"
];
$("#comu").autocomplete({
source: comunidades
});
});
If that doesn't work, then you'll need to tell us which autocomplete library you're using.
NB: $(document).ready(...) is deprecated:
jQuery offers several ways to attach a function that will run when the DOM is ready. All of the following syntaxes are equivalent:
$( handler ) $( document ).ready( handler ) $( "document" ).ready( handler ) $( "img" ).ready( handler ) $().ready( handler )
As of jQuery 3.0, only the first syntax is recommended; the other syntaxes still work but are deprecated.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hallo!!
thanks a lot, for your prompt reply, so, I followed your advices, but it doesn´t work..
$(window).on("load",function(e){
var comunidades=[
"Galicia",
"Asturias",
"Cantabria",
"Euskadi"]
$("#comu").autocomplete({
source:comunidades
});
});
"If that doesn't work, then you'll need to tell us which autocomplete library you're using"
?>
Thank u!!!
|
|
|
|
|
Uppss!!
I forgot to add tue links to the Jquery Library...
?>
<html>
<head>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
</head>
|
|
|
|
|
$(function(){
var comunidades = [
"Galicia",
"Asturias",
"Cantabria",
"Euskadi"
];
$("#comu").autocomplete({
source: comunidades
});
});
Assuming you have an <input> with id="comu" somewhere in your document, and you've linked to the jQuery UI CSS[^] as well as the scripts, that should work. It's virtually identical to the first example on the jQuery UI site[^].
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi!!
thanks a lot for the answer...
I had to go use a safe copy of the Projekt..becouse I finally didn`t find a solution
Greetings!!
|
|
|
|
|
Ive just started to learn JS and Ive been stuck on a memory game script Ive been messing with. Ive finally got it able to accept images, instead of text, but when it matches any 2 the cards just turn back over :/ Also when I hit the image card, the whole game freezes. Help please?
Here is code below.
<pre><!DOCTYPE html>
<html>
<head>
<style>
div#memory_board{
background: url(klematis.jpg) -repeat;
border:#FF1493 5px solid;
width:700px;
height:500px;
padding:24px;
margin:0px auto;
}
div#memory_board > div{
background: url(klematis.jpg) no-repeat;
border:#FF1493 1px solid;
width:71px;
height:71px;
float:left;
margin:10px;
padding:20px;
font-size:64px;
cursor:pointer;
text-align:center;
}
div#memory_board > div img {
height: 100%;
}
.picture{
background-size: cover !important
}
</style>
<script>
// Scripted By Adam Khoury in connection with the following video tutorial:
// http://www.youtube.com/watch?v=c_ohDPWmsM0
var memory_array = ['url("http://cs61a.org/assets/images/john-denero.jpg")','A','B','B','C','C','D','D','E','E','F','F','G','G','H','H','I','I','J','J','K','K','L','L'];
var memory_values = [];
var memory_tile_ids = [];
var tiles_flipped = 0;
Array.prototype.memory_tile_shuffle = function(){
var i = this.length, j, temp;
while(--i > 0){
j = Math.floor(Math.random() * (i+1));
temp = this[j];
this[j] = this[i];
this[i] = temp;
}
}
function newBoard(){
tiles_flipped = 0;
var output = '';
memory_array.memory_tile_shuffle();
for(var i = 0; i < memory_array.length; i++){
output += '<div id="tile_'+i+'" class="picture" onclick="memoryFlipTile(this,\ ' + i + ')"></div>';
}
document.getElementById('memory_board').innerHTML = output;
}
function memoryFlipTile(tile,val){
if(tile.innerHTML == "" && memory_values.length < 2){
index = memory_array[val]
if (memory_array[val].length > 20){
tile.style.backgroundImage = memory_array[val];
}
else {
tile.style.background = '#FFF';
if (index == "image"){
tile.innerHTML = "<div style='font-size: 20px'>" +index +"</div>"
}
else
{
tile.innerHTML = index;
}
}
if(memory_values.length == 0){
memory_values.push(index);
memory_tile_ids.push(tile.id);
}
else if(memory_values.length == 1){
memory_values.push(index);
memory_tile_ids.push(tile.id);
if((memory_values[0].length > 20) && (memory_values[1].length < 20) && (memory_values[0] == gsi_dict[memory_values[1]])){
console.log("go")
tiles_flipped += 2;
// Clear both arrays
phrase = "You found "+ memory_values[1] +"!"
alert(phrase)
memory_values = [];
memory_tile_ids = [];
if(tiles_flipped == memory_array.length){
alert("Great job naming those awesome GSI's. Get ready to play again!");
document.getElementById('memory_board').innerHTML = "";
newBoard();
}
}
else if((memory_values[1].length > 20) && (memory_values[0].length < 20) && (memory_values[1] == gsi_dict[memory_values[0]])){
console.log("go")
tiles_flipped += 2;
phrase = "You found "+memory_values[0] + "!"
alert(phrase)
// Clear both arrays
memory_values = [];
memory_tile_ids = [];
if(tiles_flipped == memory_array.length){
alert("Great job naming the CS61A staff. Get ready to play again!");
document.getElementById('memory_board').innerHTML = "";
newBoard();
}
}
else {
console.log("flip")
function flip2Back(){
// Flip the 2 tiles back over
var tile_1 = document.getElementById(memory_tile_ids[0]);
var tile_2 = document.getElementById(memory_tile_ids[1]);
tile_1.style.background = "url(klematis.jpg)";
tile_1.innerHTML = "";
tile_2.style.background = "url(klematis.jpg)";
tile_2.innerHTML = "";
// Clear both arrays
memory_values = [];
memory_tile_ids = [];
}
setTimeout(flip2Back, 700);
}
}
}
}
</script>
</head>
<body>
<div id="memory_board"></div>
<script>newBoard();</script>
</body>
</html></pre>
|
|
|
|
|
Hey guys,
I need some hep finishing my javascript assignment. This is what I have so far:
randomlnt(Math.random(0-9));
var quoteElem = document.getElementByTagName("quote")[0];
var randomQ = randomlnt;
function randomlnt(lowest, size) {
lowest = Math.floor(size);
size = Math.random(0-9);
}
getQuote(randomQ); {
document.getElementByTagName("quoteElem").innerHTML = quoteElem;
}
The instructions are a total of 4 steps, some of which I have completed but I am not sure if they are correct or placed in the right area.
Here are the steps:
5. Directly below the comment section, insert a function named randomint that will be used to generate a random integer. Specify two parameters for the function named lowest and size. The lowest parameter will specify the lowest possible value for the random integer and the size parameter will set the number of integers to be generated. Use those two parameter values and the Math.floor() and Math.random() methods to return a random integer within the specified range.
6. Above the randomInt() function insert a command to call the function, generating a random integer from 0 to 9. (Hint: Remember that the size of this interval is 10 because it includes 0 in its range.) Store the result from the function in the randomQ variable.
7. Create a variable named quoteelem that references the first element in the document that has the quote tag name.
8. Call the getQuote() function using the randomQ variable as the parameter value to generate a random Jane Aust
|
|
|
|
|
ghazabaz wrote: insert a function named randomint
ghazabaz wrote: function randomlnt(
You might want to start by using the name you were told to use. There's a difference between a lower-case I and a lower-case L.
ghazabaz wrote: Use those two parameter values and the Math.floor() and Math.random() methods to return a random integer within the specified range.
Your function doesn't return anything. And it completely ignores the size parameter.
ghazabaz wrote: Math.random(0-9)
That passes a single argument of -9 to the Math.random function. But that function doesn't take any parameters, so it's ignored.
Math.random() - JavaScript | MDN[^]
ghazabaz wrote: randomlnt(Math.random(0-9));
Your function expects two parameters. You are only passing one parameter. You are also throwing away the value that your function isn't returning yet.
ghazabaz wrote: var randomQ = randomlnt;
That stores the function in the variable randomQ . Your instructions were to store the return value in that variable.
ghazabaz wrote: getQuote(randomQ); {
document.getElementByTagName("quoteElem").innerHTML = quoteElem;
}
That throws away the return value of the getQuote function. It then tries to set the innerHTML of every <quote> element in the document to the first quote element, which isn't going to work.
You need something more like:
quoteElem.innerHTML = getQuote(randomQ);
NB: The MDN documentation for Math.random includes an example that's almost what you need for #5 - generating a random integer between 0 and max - 1 . You should be able to adapt that to your requirement with a little basic arithmetic.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Richard, thank you very much for the reply.
The text does not mention anything about returns, that is why I wrote it as it is
So for the return value, do I insert inside the calling of the randomInt(); function or within its definition?
randomInt(); {
randomQ;
}
OR
function randomInt(lowest, size) {
size = Math.random(0-9)
lowest = Math.floor(size);
return randomQ;
}
Here is what I have so far:
randomInt(); {
return randomQ;
}
var quoteElem = document.getElementByTagName("quote")[0];
var randomQ;
function randomInt(lowest, size) {
size = Math.floor(Math.random() * 10);
lowest = ???;
}
document.getElementById("quoteElem").innerHTML = getQuote(randomQ);
I am trying to figure out the lowest parameter of the randomInt function now. How will I set it up according to the instructions: "to specify the lowest possible value for the random integer" ???
**EDIT**
How about if I use the Math.min() function for the lowest parameter?
function randomInt(lowest, size) {
size = Math.floor(Math.random() * 10);
lowest = Math.floor(Math.min(size));
}
modified 9-Nov-18 12:15pm.
|
|
|
|
|
ghazabaz wrote: Use those two parameter values and the Math.floor() and Math.random() methods to return a random integer within the specified range.
ghazabaz wrote:
function randomInt(lowest, size) {
size = Math.floor(Math.random() * 10);
lowest = Math.floor(Math.min(size));
}
Again, that function isn't returning anything. And you're ignoring the parameters - you immediately overwrite size with a random value, and then overwrite lowest with the value of size .
Look at the demo on the MDN site[^] again:
function getRandomInt(max) {
return Math.floor(Math.random() * Math.floor(max));
}
Breaking that down a bit:
function getRandomInt(max) {
var number = Math.random();
var maxInt = Math.floor(max);
var numberInRange = number * maxInt;
var result = Math.floor(numberInRange);
return result;
}
That's almost exactly what you're trying to do. The difference is, you need to translate the random number to a range that's greater than or equal to Math.floor(lowest) , and less than (Math.floor(lowest) + Math.floor(size)) . You can use some fairly simple arithmetic to do that.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
plz drop the link as the response to guide me to learn javasript,,....that you know..
|
|
|
|
|
|
You didn't include any links ... nor have you attributed the source of these words
How to learn JavaScript in three months - Quora[^]
There is a zero-tolerance to plagiarism on this site so please ensure that you properly attribute the source of any information you post.
|
|
|
|
|
How many ways can you output loop information to the browser?
|
|
|
|
|
As many as you have loops.
|
|
|
|
|
prevent validation of the form if numbe1 <number 2
|
|
|
|
|
Your question itself is an answer, only written in pseudocode.
if(number1 < number2) {
} else {
} The number1 and number2 values you need to take care of, where they are coming from. Perhaps a document.getElementById("number1") , or something like that?
Document.getElementById() - Web APIs | MDN
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Hola!
es mi primer mensaje en el foro..no encontré subforo de jquery,pero espero que sea el sitio adecuado
Estoy desarrollando un proyecto con PHP en Zend Framework, y en una vista recojo los datos de nuevo cliente con el típico formulario.
hay que introducir (en textbox) 1º Comunidad y 2º Provincia..la idea es que si el usuario teclea "Galicia" en el siguiente textbox se muestren sus provincias...
el caso es que el primer autocomplete funciona, pero el segundo, no y no se que estoy haciendo mal, no me da error el debuger de Chrome, he probado en Firefox, y tampoco..agradecería algo de ayuda
Dejo un copy paste de codigo..gracias por anticipado
<html>
<head>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<!--<link rel="stylesheet" href="/resources/demos/style.css">-->
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
</head>
<script type="text/javascript">
$(document).ready(function(){
var comunidades=[
"Galicia",
"Asturias",
"Cantabria",
"Euskadi",
"Navarra",
"Cataluña",
"Comunidad Valenciana",
"Murcia",
"Andalucia",
"Canarias",
"Baleares"
];
var provingal=[
"La Coruña",
"Lugo",
"Orense",
"Pontevedra"
];
$("#comu").keyup(function(){
$(this).autocomplete({
source:comunidades
});
});
$("#provin").keyup(function(){
var comu=document.getElementById("comu").value;
switch(comu)
{
case"Galicia":
$(this).autocomplete({
source:provingal
});
break;
}
});
});
|
|
|
|
|
Es un sitio en ingles
This is an english site.
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
The task
I work with Angular and Chart.js (just started working with both for the first time) and need to import a recordset into Chart.js to be displayed as a multi-axis line chart. At the moment I am displaying some dummy data for visualization which works flawless.
The recordset to be displayed is a record of statistical data stored in a local MS SQL database table. There are three columns that need to be displayed from the table in Chart.js.
1. ExeTimeStamp (in SQL server defined as the following style --> "ODBC canonical date and time with milliseconds." http://www.blackwasp.co.uk/sqldatetimeformats.aspx)
2. LogTimeStamp (same as above ExeTimeStamp style)
3. TaskResult (in SQL server defined as a String, holds thousands of recordsets, each containing 15 pairs of "value" and "label" data)
The challenge
By means of the following tutorial (http://www.tutorialsteacher.com/nodejs/access-sql-server-in-nodejs) I was able to connect to the database and to retrieve the data for all three columns to be displayed in Chrome which results in the following JSON output...
{"recordsets":[[
[{
"ExeTimeStamp":"2018-08-11T08:06:47",
"LogTimeStamp":"2018-08-11T08:07:29",
"TaskResult":[
{"value":"1452","label":"Google readings"},
{"value":"1618","label":"Navigate to 'log on' page"},
{"value":"5467","label":"Log in"},
{"value":"2420","label":"Find user"},
{"value":"1500","label":"Click on 'active cases'"},
{"value":"3084","label":"Click on case"},
{"value":"1350","label":"Click on 'documents'"},
{"value":"652","label":"Click on download PDF icon"},
{"value":"5008","label":"Log in via login client"},
{"value":"1","label":"Wait for down-load/check for PDF in PDF viewer"},
{"value":"1299","label":"Click on extended search"},
{"value":"1267","label":"Input search term"},
{"value":"5004","label":"Execute search},
{"value":"1696","label":"Log out"},
{"value":"30366","label":"Total without google readings"
}]
//...remaining recordsets...
}]],"output":{},"rowsAffected":[20461]}
This data now needs to be mapped to Chart.js so it is possible to read the data into the chart display itself.
Having looked at other suggestions, my approach would be to create a new typescript class looking somewhat like this...
export class livelogs implements OnInit {
constructor() { }
ngOnInit() {
}
exetimestamp: Date;
logtimestamp: Date;
taskresult: string[];
}
...in order to make data available for reading by Chart.js from that class.
However each recordset with the 15 pairs of "value","label" data in TaskResult needs to be accessed one pair at a time and mapped individually to Chart.js so each line (and intersecting point) in the chart gets its own value and label.
Therefore, I am in doubt as to whether my approach is the right one, nor if or how it could be actually made to work.
Can anyone point me into the right direction here?
Thanks in advance for any input.
The chart type from Chart.js which I am using now can be seen here...
http://www.chartjs.org/samples/latest/charts/line/multi-axis.html
Note: If someone might wonder why TaskResult wasn't/isn't separated rather into multiple columns, holding each one pair - as it would be a better solution to the problem - I agree, but have already asked the responsible about this option. Since the statistical information in the future will have to be accessed by many users by means of a customized search option, plus that the same information needs to refresh other more specific graphs at a fixed time-interval, the reasoning is that the server would be taxed to hard with constant requests if more columns had to be accessed and the load therefore too high, which makes this possibility a no-go.
|
|
|
|
|