comparing two strings and printing - JavaScript Help


i have a function where I would like to compare two strings

depending on the position of each letter I need to format each letter differently...

if the letter is in the right place print it Red
if the letter is in the word, but in the wrong place, print it in blue
if it's not part of the word at all, make it black

how would i do that with the function makeAGuess() below
Also, the printout needs to go in the "guessed" text box
which i know i use document.myForm.guessed.value=...

function makeAGuess() { var myInput=document.myLingo.input.value; document.myLingo.input.focus(); var cc= " "; if (!document.myLingo.input.value) { alert("Guess a letter.") } else { for(i=0; i
Posted On: Wednesday 2nd of January 2013 12:40:21 AM Total Views:  313
View Complete with Replies

RELATED TOPICS OF JavaScript PROGRAMMING LANGUAGE




Online Puzzle

This program is supposed to generate an online crossword puzzle for a newspaper. I cannot get any of my functions to work and would greatly appreciate some help figuring out what is going on. Users should be able to directly type their answers into the puzzle and navigate the puzzle by pressing the arrow keys on their keyboard. Typing a letter should move the cursor to the next cell. A user should also be able to toggle whether typing is entered vertically or horizontally by pressing the spacebar. The current cell in the puzzle should be yellow. If a user enters a correct letter into a cell, the background should be changed to light green. If an incorrect letter is entered, a light red background should be displayed. Blank puzzle cells should be displayed with a white background. /* New Perspectives on Javascript Tutorial 8 Case Problem 3 Filename: makepuzzle.js Global Variables: clues_across Array of the clues in the puzzle rows clues_down Array of the clues in the puzzle columns words Array containing the puzzle solution Functions List: writeClues() Write the clues into the puzzle showAns() Display the puzzle solution */ var clues_across = new Array(); clues_across[0]="1: Personal servant"; clues_across[1]="2: Home"; clues_across[2]="3: Measure"; clues_across[3]="4: Quaking tree"; clues_across[4]="5: City in Northern England"; var clues_down = new Array(); clues_down[0]="1: Of the visceral nerve"; clues_down[1]="2: To lower in rank"; clues_down[2]="3: Diamond magnifier"; clues_down[3]="4: Sharpened"; clues_down[4]="5: Children older than 12"; var words = new Array( "V","A","L","E","T", "A","B","O","D","E", "G","A","U","G","E", "A","S","P","E","N", "L","E","E","D","S"); function writeClues() { for (i=1;i
VIEWS ON THIS POST

48

Posted on:

Wednesday 21st November 2012
View Replies!

html entity decode

anybody have a browser compatible html entity decoding function
VIEWS ON THIS POST

142

Posted on:

Saturday 24th November 2012
View Replies!

RegExp matching a URL

I'm trying to write a demo page for my site that works completely on AJAX. What I mean by this is that the page will stay the same, but load new pages by changing the of the document. I'm writing a script that will take every link and decide whether to add the attribute target="_blank" or onClick="getPageWithAJAX();" Right now I'm writing the regular expression for it, which is working perfectly in the Regex tester . The problem is, it won't return a match when I put only "index.php" for the URL. Here is my coding: ajax.js alert(window.location.host); function getPage(url) { var domain = new RegExp("/(" + window.location.host + ")|(^\/.*)|(^[\w\d]*\.[\w\d]{2,})/", "i"); if (domain.test(url)) alert(url + ": Same domain"); else alert(url + ": Different domains"); } I included the alert() s so that I can see if the match was made or not, for debugging purposes. home.php AJAX Website // Copyright (c) 2009 Wurbo // Use only with explicit permission from Wurbo This should alert: Different domains Same domain Same domain Different domains But on the third one, it's giving me "different domain". Anybody know why
VIEWS ON THIS POST

82

Posted on:

Saturday 24th November 2012
View Replies!

Jquery : get elements by index from the wrapper set

, While playing with jquery i've come across the following situation : $(document).ready(function(){ $("div")[0].css("background-color","blue"); }); I get an error everytime i try to call any method on a particular element from the wrapper set . I tried with the get() $("div").get(0); Same stuff . I can't spot what the problem is . Thank u
VIEWS ON THIS POST

144

Posted on:

Saturday 24th November 2012
View Replies!

Ie Display (mozilla Is Ok)

! I got a Web Site ( www.papikos.com ) which shows well in MOZILLA (check it out). In IE is shows bad, on the left, right side too much space and the header is also not good (please check it too). Can somebody help with the according SCRIPT to make it look nice in IE too You can send reply directly to my e-mail (>snipped
VIEWS ON THIS POST

57

Posted on:

Saturday 24th November 2012
View Replies!

javascript code

currently iam doing the project in java with jsp,javascrpit and html ,oracle backend the problem is we cal as combo box (or) drop down list all these are 5 lists .in that if u select any one item in the first drop down list some other names are there those have to be display in the second drop down list like that the third processs is also same ok plz suggest about that.
VIEWS ON THIS POST

124

Posted on:

Sunday 25th November 2012
View Replies!

The Message Snake

You probably have seen those message snakes following the cursor on a web page. Well, the javascript code is not too complex, so let's look at it ...
VIEWS ON THIS POST

140

Posted on:

Sunday 25th November 2012
View Replies!

HTML CHM file

can any one tell me how to create a html help file in detail. Actually i already tried for that even i have created but the problem is i don't no how to create tree in content file. and when i passing the image url to my local machine and compile the project and run it working great. but when i put this file on other machine i can't see any the images. guide me how to do this. if you have example please give me., I believe for the images you need to make them available on the other machine as well, by saving them in the same path as on your local machine, else use a server to host the images and use that url instead to access them. Can you specify which tool you are using to make the chm file
VIEWS ON THIS POST

115

Posted on:

Sunday 25th November 2012
View Replies!

Slideshow Messed-up

[IMG]http://i1235.photobucket.com/albums/ff429/rakwel10/pix.jpg[/IMG] The picture above may not be that clear but this is my website created in Wordpress. As you can see, the slideshow is messed up. When the first slide will show up, the next slide is showing too under the first slide. When I try to zoom out the website and refresh it, its getting arranged. What do you think is the problem
VIEWS ON THIS POST

143

Posted on:

Sunday 25th November 2012
View Replies!

dynamic change of date in a form

Write a javascript function that reads the month from the form field and then updates the values in the today field (similar to your jsp function) with values stopping at the correct upper limit. Then call this function in the onchange event on the month select.
VIEWS ON THIS POST

145

Posted on:

Sunday 25th November 2012
View Replies!

flash resize with javascript

, I would like to have a dynamic resize slider for a flash game, I am trying to do something like the slider here http://www.agame.com/game/funny-cars.html . Does anyone know how I should go about this, my site is http://tsgs.tk .
VIEWS ON THIS POST

133

Posted on:

Sunday 25th November 2012
View Replies!

list box(combo box)

hi frnds, iam a java developer, i need to add elements in list box dinamically, for example in my listbox data retrieve from database at runtime i.e., girls when user enter details he need option boys in the list...then he can able to enter boys in list box just like enter in textbox...is it possible..if possible..plz provide the code...thnx..
VIEWS ON THIS POST

125

Posted on:

Sunday 25th November 2012
View Replies!

Passing a lot of data

I could use a little help here. I have goodled with not much luck. I have been at this for a bit and would appreciate suggestions. I have a form (A.php) that collects a lot of data. When I post ...
VIEWS ON THIS POST

109

Posted on:

Sunday 25th November 2012
View Replies!

thousand seperator function

Hi Not telling much, because im just about to take this computer and throw it out if the window! function format(number) { var s, i, rev; s = number.toString(); s.split(''); s.reverse(); i = 3; while (i < number.length) { s.splice(i, 0, '.'); i+=3; } s.reverse(); s.join(''); return s; } eg: number = 1124235 / number = -125123 what i try to do: number = 1.124.235 / number = -125.123 no need for decimals, only integer I HATE Javascript!!!!! cheers This post has been edited by Toxicterror: 10 July 2012 - 10:06 AM
VIEWS ON THIS POST

107

Posted on:

Monday 26th November 2012
View Replies!

XHTML Page With Javascript to Write to a MySQL Database

hey , i have a project where i have to design a simple site. what needs to be done is this. create an XHTML for a users first and last name. Create A Javascript code that can read the data from that and write to MySQL database that stores the names. Also have that Javascript code be able to delete a name from that database. NO CHECK WILL BE NEEDED FOR THE SECOND PART OF THE JAVA CODE. WE CAN ASSUME THE NAME TO BE DELETED IS ALREADY IN THE DATABASE! Does anyone have any idea of a good tutorial page explaining MySQL and Javascript Im clueless as to how to connect the FORM to the JSP to edit the database. Here's the Exact Rules Make a Database with a table named Members with a single attribute clubMembers. An HTML Form allows members to be added to the data base by transmitting a Form input variable newMemberName to a designated JSP program which adds members to the database. Verify the additions by manually displaying the database tables before and after additions. Test and Document appropriately. You will be using the MySql database. 1. Add a password field to the form and protect the database with a password, rejecting access if the password fails. Use POST method on form so password is not overtly exposed in the query string. 2. Use a radio button option on the form to allow the user to either insert or delete a member from the database. You can assume that if the user provides a name to be removed then that name is actually already in the database and is unique. Upload your files to the public_html folder of your AFS account.. ALSO, please upload your files plus the url where your files are located to WebCt using the submission form under the assignment icon. The time stamp recorded by WebCT will be the timestamp that I use to determine if your assignment is on time or not. This post has been edited by newkid34: 04 April 2010 - 05:00 PM
VIEWS ON THIS POST

65

Posted on:

Monday 26th November 2012
View Replies!

Text from a textbox to a product description

Hi . A friend of mine has a web store at bigcartell(HTML,CSS,JavaScript) and needs an extra textbox (which can be created within div or form) on specific products where costumers can add their personalised message to the product. I wonder how could I add this message to the order or product description when customer do their orders.
VIEWS ON THIS POST

88

Posted on:

Monday 26th November 2012
View Replies!

Dropdown submit without refresh

So my code is simple html, I need it to select value when submit and if value= that number, submits something like: "Your number is 1"(without refreshing the page).
VIEWS ON THIS POST

84

Posted on:

Monday 26th November 2012
View Replies!

Calculation JS

, i'm trying to calculate the value of checkbox that chosen (onclick or onsubmit calculate the value).What i'm doing wrong //
VIEWS ON THIS POST

119

Posted on:

Monday 26th November 2012
View Replies!

Find all dropdownlist's id using jquery

I have a panel named "listState" on my aspx page Now in that panel i have number of dropdowns. I want id of that all dropdownlist present in "listState" How can i do this using JQUERY I tried following code $('#').find("select") But it doesnt gives me id of all dropdownlist. What to do to achieve this.
VIEWS ON THIS POST

93

Posted on:

Monday 26th November 2012
View Replies!

PHP Select, Jquery Ajax

I have a php function that list all of the countries from my database as a select option, then based on what the user selects for their country im using jquery to make an ajax call and get all of the states/regions for that country. This part works fine. I'm running into an issues, as when a user login's in to edit their profile, how would I make the select change based on what is in the databse. This makes the options. Then this is the jquery $("#country").change(function() { var ctry = $(this).val(); $.get("core/ajax/states.php", { country: ctry }, function(data) { var opt = ''; if (!data) {} else { $.each(data, function(n, val) { if(!n){} else{ opt += '' + val.name + ''; } }); $("#state").html(opt); } }, 'json'); }); $("#country").change();
VIEWS ON THIS POST

118

Posted on:

Monday 26th November 2012
View Replies!

please help me out

hi friends i want to apply javascript on the the go-btn so if i do give wrong password the alert box should pop up itryed but i didnt figure it out....please help me out.. below is the code function button(){ var user =document.getElementById("go-btn").value; if($password!="amry") alert('You are very brave!'); else alert('A wise decision!') Login LOGIN AREA FOR ZMS Username Password /////////// here is the go btn ///////////////// Developed by AMRY Soft
VIEWS ON THIS POST

141

Posted on:

Monday 26th November 2012
View Replies!

php mysql ajax populate multiple textbox

Dear ajax expert, http://www.w3schools.com/php/php_ajax_php.asp Refer to the link, using the sample, I'm able to use php ajax to populate 1 text box which I've already pre-define (not using "echo '
VIEWS ON THIS POST

188

Posted on:

Monday 26th November 2012
View Replies!

Assig value to php from javascript

I like send get a value from javascript to php. but i coul'nt get the value. I know how to get from php to javascript but not from javascript to php. Can u helpme.
VIEWS ON THIS POST

61

Posted on:

Monday 26th November 2012
View Replies!

font input with javascript and css

I want to make an online input similar to microsoft word or the input in hotmail. In other words I want to make some kind of input form which will allow me to include different fonts and different sizes in the input area. My first attempt has been to use a standard textarea and try to dynamically change the style used with javascript, but that changes all of the input. After that I tried using an embedded frame and javascript to monitor key inputs and write to the frame, but if I do that I lose all of the built in functionality of a textarea such as the blinking line. I think something like this should be possible as I've seen it done in hotmail and gmail. Does anyone know anyway of doing something like this Do I have to learn activex or something if I want to make something along these lines Thank you for your help.
VIEWS ON THIS POST

112

Posted on:

Monday 26th November 2012
View Replies!

Change image every set seconds, plus back and forth?

. What I need is very simple in concept, although I am the worst in the world (not really) at JavaScript. I basically want to make a displayed image change, no special effects, every set amount of seconds. I also want to have a forward and backward image button to let you immediately switch while still continuing the timed changing. I would really love some help! P.S. It would be helpful to have an external script to shorten my page's code. THANKS! -Keavon
VIEWS ON THIS POST

132

Posted on:

Monday 26th November 2012
View Replies!

Help with pop-up window position

Greybox, the pop-up window: http://orangoo.com/labs/GreyBox/ I'd just like to know how I can get it to pop-up not in the center of the page. I'd like it to pop-up on the left side of the page. Is that possible If so can you help me accomplish this It's ben suggested to change the CSS styles, but I and others haven't succeeded there. It may need additional code.
VIEWS ON THIS POST

86

Posted on:

Monday 26th November 2012
View Replies!

Cant use math addition on two variables. - JavaScript Help

,I have two variables which both hold different integer values that i would like to use addition on and make the answer into a new variable but due to js function that adds variables together with a + I cant seem to to use math addition on the two variables. Note: One variable is an array but in previous function subtraction worked fine in same situationBelow is the snippet of the code that wont work
VIEWS ON THIS POST

108

Posted on:

Tuesday 27th November 2012
View Replies!

jQuery drag/drop fails on ie9. Confused about hotfix - JavaScript Help

This is my development box: http://neucart.com/demo/. Items can be dragged/dropped into the cart (grab the image). This fails in ie9.The issue is known and addressed here:http://forum.jquery....not-work-in-ie9I tried to add the hotfix. Doesn't work.I tried to upgrade all of my jQuery library but that made things worse (drag/drop failed on all browsers). I'm more of a server-side developer; can someone help me out
VIEWS ON THIS POST

108

Posted on:

Tuesday 27th November 2012
View Replies!

Problem in this Code

when i click plus ( + ) and minus ( - ) is not working.. AMF / Aldric's #popupbox { margin: 0; margin-left: 40%; margin-right: 40%; margin-top: 120px; padding-top: 10px; width: 25%; height: 180px; position: fixed; background: #660066; color: #00FF00; border: solid #000000 2px; z-index: 9; font-family: arial; visibility: hidden; } var products = new Array ("lapis","tite","manok"); var list = new Array; var add = new Array; var sub = new Array; var ctr = 0; var bilang=0; document.oform.quantity.value=bilang; function compute(ope) { if(ope == "add") { bilang+=1; document.oform.quantity.value=bilang; } else if(ope == "sub") { if (bilang == 0) { document.oform.quantity.value=0; } else{ bilang -=1; document.oform.quantity.value=bilang; } } } function show_gamecards() { document.getElementById('gamecards').style.visibility = "visible"; } function hide_gamecards() { document.getElementById('gamecards').style.visibility = "hidden"; } PRODUCTS WHAT'S NEW ABOUT US DEVELOPERS PRODUCTS: School Supplies Toys Fassion Accessories Cellphone Accessories Game Cards Game Cards Quantity Price Quantity Price Quantity Price Quantity Price Quantity Price Quantity Price Quantity Price Quantity Price Quantity Price Quantity Price
VIEWS ON THIS POST

104

Posted on:

Thursday 29th November 2012
View Replies!

Modify CoDrop's interactive twitter map for #hashtags instead of u

http://tympanus.net/...ive-google-map/ ! I am new to javascript & apis. I saw this cool open source code and I want to be able to edit it. Instead of placing twitter users on a map, I want to place tweets with a specific hashtag. Any advice
VIEWS ON THIS POST

115

Posted on:

Thursday 29th November 2012
View Replies!

UI Libraries

Are there any other Javascript UI libraries other than ExtJS 2.0 and Yahoo! UI library that are as good as ExtJS but without the license restrictions that ExtJS imposes on commercial usage I am after tree controls that have ...
VIEWS ON THIS POST

104

Posted on:

Friday 30th November 2012
View Replies!

FAQ Topic - Which newsgroups deal with javascript? (2008-05-31)

----------------------------------------------------------------------- FAQ Topic - Which newsgroups deal with javascript ----------------------------------------------------------------------- The official Usenet newsgroup dealing with javascript is comp.lang.javascript. There are other newsgroups but many of them are not carried by most news feeds. clj is an unmoderated newsgroup. -- ...
VIEWS ON THIS POST

90

Posted on:

Friday 30th November 2012
View Replies!

TextArea Horizontal Scrolling

I hope that this is an appropriate question for this forum. So far I have had some difficutly getting an answer to my problem. I have a java application with a textarea. I would like the horizontal scroll bar to ...
VIEWS ON THIS POST

106

Posted on:

Friday 30th November 2012
View Replies!

FAQ Topic - Which newsgroups deal with javascript? (2008-04-02)

----------------------------------------------------------------------- FAQ Topic - Which newsgroups deal with javascript ----------------------------------------------------------------------- The official Usenet newsgroup dealing with javascript is comp.lang.javascript. There are other newsgroups but many of them are not carried by most news feeds. clj is an unmoderated newsgroup. -- ...
VIEWS ON THIS POST

106

Posted on:

Friday 30th November 2012
View Replies!

How to display 'style'ed text in a textaea or... ???

The scenario is a RTF(Rich Text Format) editor where I can input text and meanwhile display 'style'd text or multimedia( i.e bold fonts, pictures, movies ) in the same box... I am currently using some HTML tags in textarea and ...
VIEWS ON THIS POST

140

Posted on:

Friday 30th November 2012
View Replies!

IE 7 memory leak when you remove an element from page, or Drip bug?

Hi. I have a element, with in it and inside , all created statically (e.g. poresent in HTML when the page loads). Later I execute the code that adds reference to td in question to a JS ...
VIEWS ON THIS POST

147

Posted on:

Friday 30th November 2012
View Replies!

getElementById problem

and
I am trying to hide text inside
tags until a link is clicked. The following code example reveals the hidden text before the link is clicked. Can anyone point me in the right direction so I can ...
VIEWS ON THIS POST

235

Posted on:

Friday 30th November 2012
View Replies!

Re: Create a string with (n) copies of the same character

In microsoft.public.scripting.jscript message , Sat, 22 Sep 2007 09:11:42, Anthony Jones posted: >"Dr J R Stockton" wrote in message >news:5CmvgXeYwD9GFw8X@invalid.uk.co.demon.merlyn.invalid... >> In microsoft.public.scripting.jscript message > GP03.phx.gbl>, Fri, 21 Sep 2007 08:06:55, Anthony Jones >> posted: ...
VIEWS ON THIS POST

90

Posted on:

Friday 30th November 2012
View Replies!

new String( "foo" ) VS. "foo"

Why does "foo" instanceof String return false It just seems counterintuitive to me. I mean, sure, I can always check the constructor: var fooVar = "foo"; var isString = fooVar.constructor == String; var isNotStringObject = fooVar instanceof String; It seems ...
VIEWS ON THIS POST

66

Posted on:

Friday 30th November 2012
View Replies!

Re: action url change on submit form

On May 23, 7:57 pm, "MZ" wrote: > Is it possible to change URL form action on submit form... function setFormAction(frm) { frm.action = "new_URL_goes_here"; return true; }
....
...

VIEWS ON THIS POST

103

Posted on:

Friday 30th November 2012
View Replies!

Disable script debugging from within script - IE

I was just wondering if it is possible to disable script debugging in IE from within a script. I know I can disable it manually through the IE tools menu, but is it possible to disable it from within ...
VIEWS ON THIS POST

96

Posted on:

Friday 30th November 2012
View Replies!

Assign a function with parameters to an object

How do I assign a function with parameters to an object in javascript My intension is to call the function as, object.myFunction(param1,param2). -- sunil philip, S/W Engineer...
VIEWS ON THIS POST

142

Posted on:

Friday 30th November 2012
View Replies!

Confirmation msg box with custom Title

I need confirm Msgbox with custom title
VIEWS ON THIS POST

113

Posted on:

Sunday 23rd December 2012
View Replies!

greybox redux - refresh parent on close - JavaScript Help

Hi all, I am using greybox redux (a cut down version of orongelabs greybox - using jquery) and I when the popup window is closed I wish to refresh the parent window.The methods I have tried for the full versions do not work in the redux version.The whole script is just this:/* Greybox Redux * Required: http://jquery.com/ * Written by: John Resig * Based on code by: 4mir Salihefendic (http://amix.dk) * License: LGPL (read more in LGPL.txt) */ var GB_DONE = false; var GB_HEIGHT = 400; var GB_WIDTH = 400; function GB_show(caption, url, height, width) { GB_HEIGHT = height || 400; GB_WIDTH = width || 400; if(!GB_DONE) { $(document.body) .append("" + ""); $("#GB_window img").click(GB_hide); $("#GB_overlay").click(GB_hide); $(window).resize(GB_position); GB_DONE = true; } $("#GB_frame").remove(); $("#GB_window").append(""); $("#GB_caption").html(caption); $("#GB_overlay").show(); GB_position(); if(GB_ANIMATION) $("#GB_window").slideDown("slow"); else $("#GB_window").show(); } function GB_hide() { $("#GB_window,#GB_overlay").hide(); } function GB_position() { var de = document.documentElement; var w = self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth; $("#GB_window").css({width:GB_WIDTH+"px",height:GB_HEIGHT+"px", left: ((w - GB_WIDTH)/2)+"px" }); $("#GB_frame").css("height",GB_HEIGHT - 32 +"px"); } and the function: var GB_ANIMATION = true; $(document).ready(function(){ $("a.greybox").click(function(){ var t = this.title || $(this).text() || this.href; GB_show(t,this.href,470,600); return false; }); }); and to use:Hope someone can help!
VIEWS ON THIS POST

82

Posted on:

Friday 28th December 2012
View Replies!

javascript doesn't read XML - JavaScript Help

My code is like this:http://pastebin.com/xnLYU37fThe only alerts that I get is this:"starting load images.""copy""done"
VIEWS ON THIS POST

110

Posted on:

Tuesday 1st January 2013
View Replies!

Putting a Minecraft skin together - JavaScript Help

all, I'm new to java script and for those of you that play minecraft, you should know that you can have a skin. Them skins are stored at minecraft.net and are public. I would like to get the skin of a user and using java script put it together in a 2D view and enlarge the size. I have come across something that does do this here: http://code.google.c...Renderer.jsr=2This will put together a skin, but I have been at it for days trying to get the image bigger without getting it blurry. I can make it bigger but it always goes blurry, I know it can be done as I have seen sites do it but in 3D. I want to get the head of the skin and enlarge it to 64px - 64px.If anyone could write the code for this it would be amazing and if they have time write comments as I would love to learn this sort of thing.Example of a skin : http://www.minecraft...n/Ruddy2007.pngThat is my skin.Thank you and good luck.
VIEWS ON THIS POST

66

Posted on:

Tuesday 1st January 2013
View Replies!

How do I wait for javascript file to be fully loaded ? - JavaScript Help

I need to wait for a javascript file to be loaded by the client browser before executing rest of the script.(I dont have access to the HEAD tag, because the script I develop is being called from other users page).Here is what I am trying to do without success: echo "document.write(\"" ."\");"; echo "document.write(\"var newScript; newScript = document.createElement('script'); " ."newScript.type = 'text/javascript'; " ."newScript.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js'; " ."document.getElementsByTagName('head')[0].appendChild(newScript); \");"; sleep(5); $list = "" ."" ."TITLE" ."DESC" ."" ."" ."$(function() {" ."$(window).scroll(function(){" ."var distanceTop = $('#last').offset().top - $(window).height();" ."if ($(window).scrollTop() > distanceTop)" ."$('#slidebox').animate({'right':'0px'},300);" ."else " ."$('#slidebox').stop(true).animate({'right':'-430px'},100); " ."});" ."$('#slidebox .close').bind('click',function(){" ."$(this).parent().remove();" ."});" ."});"; echo "document.write(\"$list\");"; exit;
VIEWS ON THIS POST

47

Posted on:

Tuesday 1st January 2013
View Replies!

Canvas Re-Draw For Animation - JavaScript Help

HiHere is the updated code. Here you can see the bird is re-drawn by clearing the rectangle, so that it animates the bird moving.The issue i have now is when the bird is cleared it also clears anything else in the scene where the bird currently is. So if you see $.renderScene() draws 3 trees...how can I re-draw the bird without it effecting the trees Because I have to keep re-drawing the trees as well so it looks like the trees flicker when the bird flies near them...not sure how to stop this so the trees stay on the screen while the bird moves...if i dont clear the canvas the bird will duplicate all over the scene $(document).ready ( function() { // global vars var trees = new Array(); var canvas = null; var bird = null; var birdX = 0; var birdY = 0; var posX = 2; var posY = 4; /* function: renderScene desc: renders the trees and any other objects onto the canvas - clears the canvas first to avoid animation render repeating */ $.renderScene = function() { // draw 3 trees trees[0] = new Image(); trees[1] = new Image(); trees[2] = new Image(); trees[0].onload = function() { canvas.drawImage ( trees[0], 0, 0 ); } trees[1].onload = function() { canvas.drawImage ( trees[1], 700, 10); } trees[2].onload = function() { canvas.drawImage ( trees[2], 350, 100); } trees[0].src = 'tree.png'; trees[1].src = 'tree.png'; trees[2].src = 'tree.png'; } /* function: drawBird desc: draws an animated bird */ $.drawBird = function() { // create bird image object bird = new Image(); // create onload event handler to make sure the bird // image loads - prevents crashing or halting // - this is only called once the bird src is set bird.onload = function() { // clear the canvas canvas.clearRect( birdX - 10, birdY - 10, 90,90 ); // draw the bird on our canvas canvas.drawImage ( bird, birdX, birdY ); if ( birdX + posX > 1024 || birdX + posX < 0 ) { posX = -posX; } if ( birdY + posY > 768 || birdY + posY < 0 ) { posY = -posY; } birdX += posX; birdY += posY; $('#pos').html ( 'X:' + birdX + 'Y:' + birdY ); } // load the actual bird image bird.src = "bird.png"; // Render the trees on top of the bird so the bird goes // behind $.renderScene(); } /* function: init desc: initialise the canvas and interval for bird movement */ $.init = function() { // get reference to the canvas element canvas = $('#canvas')[0].getContext ( '2d' ); // set interval to the drawBird function as 10 milliseconds return setInterval ( $.drawBird, 10 ); } // initialise $.init(); });
VIEWS ON THIS POST

112

Posted on:

Wednesday 2nd January 2013
View Replies!

Onclick help - JavaScript Help

howdy \tI'm not good with Javascript. but I know this can be done in javascript. I have a php event calendar and the event days are links. I want the links to be onclick and have a table under the calender to expand and show the events for that day. (it will need to pull the id from php into javascript and back to php)can someone help me
VIEWS ON THIS POST

53

Posted on:

Wednesday 2nd January 2013
View Replies!

Body onkeypress - JavaScript Help

I want to display a messgae (alert) whenever anyone click space in my webpage. Now, is there any way to do this other than putting the onkeypress in BODY tage Can I put onkeypress in any other place and have the same result
VIEWS ON THIS POST

298

Posted on:

Wednesday 2nd January 2013
View Replies!