Jump to content

Search the Community

Showing results for tags 'array'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








  1. Hello i try make it like: <html><head> <script type="text/javascript"> function Code() { A=["T1","T2","T3",4,2,1]; var B1=A;var B2=A;var B3=A; if (A[0]=="T2") {B1[3]=5;} if (A[1]=="T2") {B2[3]=5;} if (A[2]=="T2") {B3[3]=5;} document.getElementById('W1').innerHTML="B1:"+B1[3] document.getElementById('W2').innerHTML="B2:"+B2[3]; document.getElementById('W3').innerHTML="B3:"+B3[3]; } </script></head><body> <input type="button" value="Code it!" onClick="Code()"><br><br><br> <div id="W1"></div> <div id="W2"></div>
  2. Alright, so I am making a program that when a button that says "yo" for example, will display a prompt when click. If the answer to the prompt is a verb, then the "yo" form of that verb is displayed. So far I have a button, that when clicked has a prompt. When I enter a word in the button I can't make it display the "yo" form of the verb. Please help: Here is my javascript: function verb(verb, yo) { this.verb = verb; this.yo = yo;}//*All verbsvar estar = new verb("estar", "estoy");//*All arraysvar verbs = [estar];//*Verb translation present_yofunction presentYo(){ var verb = ver
  3. Hello so I made an array and it works fine when you refresh the page the image changes but at lower screen resolutions the image cuts of the edge. With my basic code it worked fine I was wondering what I was doing wrong. This was my old code which was just one image and at lower resolutions it would still fit on the screen <center><img src="my image url" width=47%> </center> But when I use my array it cuts of I want to make the image center and just put width=47% like the top code but not sure where to put it <script language="JavaScript"><!--function ra
  4. sir george

    array problems

    Newbie, first time ever posting. I found this script online and it works exactly as I want with the exception of sorting. On my local host it presents output in alphabetical order, but online it will not. I've tried for days to work it into an array so I could sort it, but have hit my patience wall. Can someone please show me where to insert the array and then read it back? Thanks in advance for any effort put into this topic. George dir-read-script.php
  5. Hi W3, this array-within-array should print out Students 1, 2, 3 and their averaged grades, but it's only printing out Student 3 & average, and no console errors. It works fine substituting console.log, so the problem is my innerHTML part. Thanks in advance for direction. document.addEventListener("DOMContentLoaded", function(){var grades = [[89, 77, 78], [76, 82, 81], [91, 94, 89]];var total = 0;var average = 0.0;for (var row = 0; row < grades.length; row++){ for (var col = 0; col < grades[row].length; col++){ total += grades[row][col];} average = total / grades[row].len
  6. Hi everyone. I'm trying to echo the values of an array inside HTML's <option> tag. The following should be echod: <option value="Moose Jaw,SK,Canada">Moose Jaw,SK,Canada</option> <option value="Prince Albert,SK,Canada">Prince Albert,SK,Canada</option> <option value="Regina,SK,Canada">Regina,SK,Canada</option> <option value="Saskatoon,SK,Canada">Saskatoon,SK,Canada</option> The code I attempted was: <!DOCTYPE html> <html> <body> <?php $sk=array("Saskatoon","Regina","Moose Jaw", "Prince Albert"); sort($sk); forea
  7. i am trying to create new element that contains a php returned array in it. $( "#invoice" ).append( '<td id="item"><script>getData("items.php", "item")</script></td>'); the array is returned from 'items.php' and is called with simple ajax technique. its not working, or simply i don't know how can i do that. can anyone please guide me or suggest me some better technique...?
  8. I have "Checkbox" input with multiple values. <input type="checkbox" name="drug" value="1" /><input type="checkbox" name="drug" value="2" /><input type="checkbox" name="drug" value="3" /> I want to run through this array and alert() all the values. I'm guessing I should use Jquery's .each() command but I'm not sure how to use it. the problem is, I don't understand how to use it so I can get the key and it's value. $.each($("input[name='drug']"),function(i,v){ alert(i+": "+v);}); What am I missing in the main idea?
  9. So I have a calendar that I created using JavaScript on an HTML page but now I need to create a variable that contains an array. The array needs to be a week long to-do list. Problem 1, I try to create the variable to produce the 'to-do' list but I'm not sure how to associate the array with a week out of the month. Second, I'm not sure where to plug in the variable once I have created it in order to make it show up in the calendar. Below is the script I wrote for the calendar. And help would be appreciated. Thanks! <!doctype html> <html> <head> <meta charset="UTF-8">
  10. Hello, new here and also sorta new to PHP and all that. I'm trying to find a way to select certain checkboxes and input that data into a database. And then at times go back and view and update the database. The checkboxes may also change at times and I do not want to go add a bunch of fields into the database just to see who's all in it. What I have so far is peoples names in a checkbox form where I can select names and submit it. It then implodes and inserts it into the database like so responders(2,4,47,56) Its not going to be a thing like responders(0,0,1,0) type thing. My
  11. I need to loop through an array, in the order that the items appear, and get both the key of the item and its value. I know I can use foreach to loop through an array but as far as I know I can choose between the key and the value of the current item but not get both. Here's an example of an array: <?php$SampleArray = array(55 => "car","2" => "house","boat" => "boat",0 => "engine",666 => "website",);?> It would work somehow like this: loop($SampleArray){ echo key . " - " value . "n";} And the result would be something like:55 - car 2 - house boat - boat 0 -
  12. bwouters

    php array help

    Dear reader, On my own server I created the following code that is working perfectly: $items = []; foreach ($rows as $row) { $items[] = [ "item" => $row["item"], "brand" => $row["brand"], "number" => $row["number"], "price" => $row["price"], "start" => $row["start"], "end" => $row["end"], "shop" => $row["shop"], "location" => $row["location"], "link" => $row["link"] ]
  13. I need to pass multiple data through ajax, and also should post back it in another page. but my code is not working, this is my code: var data = {page_num: page,gender: <?php echo $gender;?>this_year: <?php echo $year;?>};$.ajax({ type: "POST", url: "data.php", data: data, success: function(res) { $("#result").append(res); console.log(res); } }); POST the values(data.php): echo $page = $_POST['page_num'];echo $gender = $_POST['gender'];echo $fromyear = $_POST['this_year']; please guys help me. thnx,
  14. Good day, I appreciate that this is a popular query but I've been searching the web for answers and I've been unable to get my code to work. I'm trying to create the effect of an animated button on a website. I have a div which contains an <img/>. This image is the "animated button". I have already prepared the additional images to represent the following frames. Now, the JavaScript code I have (which I've pulled together looking at examples) is below. var navAniButton;var aniImgs;var imgAniTimer;var index;var maxImages; function updateVar() {navAniButton = document.getEleme
  15. picokojama

    OOP error

    Hi everyone, I have something like more advanced problem, so I hope someone will help. No need for looking for variables and functions matches, I have good editor, and if there is any, it is because I am translating code to english. Here I have class DBobject, which contains all common database methods, but my focus is on two: public static function find_by_sql($sql) { global $pdo; // pdo connection works fine $query = $pdo->query($sql); $object_array = array(); while($row = $query->fetchAll()) { $object_array[] = static::instantiat
  16. Hello all,I have tried so many things to get this to work but to no avail, can someon eplease help me out here with a simple script for n XML steam feed.http://api.steampowered.com/ISteamUserStats/GetGlobalAchievementPercentagesForApp/v0002/?gameid=221380&format=xml OK NOW THE ISSUE IS:I have a blank webpage which I have placed the above link into, I simply want the contents of the XML feed from the link to appear in mypage.......How do I make the contents of that url appear on the same page??SO I NEED THE SMALL SCRIPT OR HTML CODE TO DO THISAlso I would like to have the background a certa
  17. I'm working on a website that I want to be accessible to speakers of many languages but I'm wondering how to architect such a website. I seem to have two options and I hope you guys can help me choose: 1) Database I could make a table that lists all the messages and then have individual language tables with translations of those messages. Each page would then make a dozen or more queries to get all the messages/content to populate each page. I'm a bit worried about what the effect this may have on my databases and whether it is too much for them to handle in addition to all the other queries s
  18. Hello! I wanna create a form that can send sms to multiple recipient, i've created a form that uses javascript to add or remove textbox dynamically, this code successfully send sms when i fill one recipient number, but fails to send more than one recipient, and as i try to make it send sms to more than one user by making it loop, i get this error, Can someone help? i want to know how do i make this form sends sms towards multiple user Warning: Invalid argument supplied for foreach() <script language="javascript"> function addRow(tableID) { var table = document.getElementById(tableID
  19. <script>int[][] num = new int[4][5];num[1][1]={0,1,2,3,4};alert(num[1][2]);</script> This give my an error " Uncaught SyntaxError: Unexpected token ] " (shown by chrome) #for the "int[][] num = new int[4][5];" line Please help.
  20. Hello,I'm new here and to be honest it's the first time I am writing into a Forum. Until now I was only reading through various posts which considerd the same problem as I had. But now I really have no idea what to search and where my problem is. Down here is the PHP Script I have written for a Prom Vote in a nearby school. It would be really great if someone could find my mistake and correct me. <!DOCTYPE html><html lang="en"> <head> <meta charset="utf-8" /> <title></title> </head> <body> <?php$con = mysql_connect("localhost","xxx","xxxx
  21. hi. learnign JavaScript from tutorial provided at http://www.w3schools.com/js/default.asp In JavaScript Array Object section, I was presented with this script: <script>var i;var mycars = new Array();mycars[0] = "Saab";mycars[1] = "Volvo";mycars[2] = "BMW";for (i=0;i<mycars.length;i++){document.write(mycars + "<br>");}</script> I realize that this code says to increase integer value by 1 as long as i<mycars.length But i don't get what is mycars.length in this case? The length of "mycars" (6 characters in this case?) I experimented by adding additional variables: <scri
  22. how do i make this work? I need the if else statement to work.. like if i select ''samsung'' and i press submit the file must be included... but i just dont get the right code.. things that i've tried: if ($device="samsung")if (in_array("samsung" , $devices))if (in_array($devices="samsung"))and some others that i can't remember <html><body> <?php$devices = array('iphone' => 'iPhone', 'samsung' => 'Samsung', 'nokia' => 'Nokia', 'sonyericsson' => 'Sonyericsson', 'htc' => 'HTC',);echo '<form method="post">'; echo '<select>'; foreach
  23. Hello,I want to make a script to check if there is anything drawn on a canvas.I tried to use this script: [/font][font=arial,helvetica,sans-serif]var ctx = document.getElementById("canvas").getContext("2d");[/font][font=arial,helvetica,sans-serif]/* Some other code, including some drawing code[/font][font=arial,helvetica,sans-serif]All drawings are black, with alpha value 255 */[/font] [font=arial,helvetica,sans-serif]var a = ctx.[color=#000000][size=1]getImageData(0,0,room.width,room.height)[/size][/color].data.indexOf(255); // to see if anything is drawn[/font][font=arial,helvetica,sans-ser
  24. Hi guys, so i've been working on this idea for quite a while now.. the only thing is.. i'm not exactly sure how to do it.. i want to make a automatic request system where you can request phone repair service trough the company website. something like: (DROPDOWN BOX) iPhone(selected) Samsung Nokia Sony Ericsson HTC ( DROPDOWNBOX which will react on first choice, like when i select iPhone something like this should come)iPhone 3(G)SiPhone 4iPhone 4 SiPhone 5 and then ofcourse the 3rd dropdown box where you will be selecting the problem(DROPDOWN BOX)Screen brokenButton
  25. I have an array full of smaller arrays. The smaller arrays contain elements, one of which is a date. (Not a timestamp, a date such as 1, 2, 3, etc.) I want to sort the small arrays within the large array in order of this date. I don't see anything in the docs for PHP on how to do this.Let me state this another way. I have an array called $eventsThisMonth. I would like to sort $eventsThisMonth by $eventsThisMonth[every][dateOfThisOccurrance]. Thank you in advance for your great help and advice. Jeff P.S. I tried sorting "manually" using an outside loop that goes 1-31 (for the possible v
  • Create New...