JavaScript - Objects, Functions, And Methods
I have a javascript assignment I am having difficulties with. I have most of it complete but need some assistant with the last portion and that is to get my display function to work. I am sure that this is something I should know how to do but for the life of me can't seem to figure out and just need a little guidance.
Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html lang="en" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>Lab03</title> <h1> Person Information </h1> <script type= "text/javascript" charset= "utf-8"> function Person( ) { this.lastname = ' '; this.firstname= ' '; this.areacode= ' '; this.phone_number= ' '; this.show_person = ' '; } </script> <script type= "text/javascript" charset= "utf-8"> var per1 = new Person function getInput( ) { lastname= prompt("please enter your last name: "); firstname= prompt("please enter your first name: "); areacode= prompt("please enter your area code: "); phone_number= prompt ("Please enter your phone number (ex:888-8888): "); return per1; } per1= getInput( ); </script> </head> <body> <script type ="text/javascript" charset= "utf-8"> function show_person( ){ if( firstname == "" && lastname == "" ) { document.writeln( "Name: Unknown" + "<br/>" ); } else if( firstname == 'null' && lastname == 'null' ) { document.writeln( "Name: Unknown" + "<br/>" ); } else if ( firstname == "" || lastname == "") { document.writeln("Name: " + lastname); document.writeln(firstname + "<br/>"); } else if ( firstname == 'null' || lastname == 'null') { document.writeln("Name: " + lastname); document.writeln(firstname + "<br/>"); } else { document.writeln("Name: " + lastname + ", "); document.writeln(firstname + "<br/>"); } else if ( areacode == "" || phone_number == "" ) { document.writeln ("Phone: "); } else if ( areacode == 'null' || phone_number == 'null' ) { document.writeln ("Phone: "); } else { document.writeln('Phone: (' + areacode + ')'); document.writeln(phone_number); } return this.show; } </script> <noscript> <p>You must enable javascript to view all the features of this page.</p> </noscript> </body> </html> Can someone help me out and tell me what it is I need to do to make it work? I actually had it working when I was able to put all the code in the get function but was told I needed a separate display function so any input is greatly appreciated. Similar TutorialsI still can't understand very well when to use and when NOT to use parenthesis when calling/using methods and functions. Case 1: Where I commented "// No parenthesis.", could someone explain why not. And at the end, where the commen reads "// Parenthesis. ? Code: /* This function will be used as a method inside the objects. */ function getPayment() { thePayment = 250; thePayment += (this.seats == 'leather') ? 100 : 50; thePayment += (this.engine == 'V-8') ? 150 : 75; thePayment += (this.radio == 'CD Player') ? 30 : 10; return thePayment; } /* Object Constructor (prototype of the object). */ function car(seats, engine, radio) { this.seats = seats; this.engine = engine; this.radio = radio; this.payments = getPayment; // No parenthesis. } /* Creates an instance called 'my_car' out of the 'car' object. */ var my_car = new car('cloth', 'V-6', 'Tape Deck'); /* Object Initializer - automatically instantiates the object. */ var carObj = { seats: 'leather', engine: 'V-8', radio: 'CD Player', payments: getPayment // No parenthesis. No comma after last item. } // Firebug... console.log(my_car.payments()); // Parenthesis. console.log(carObj.payments()); // Parenthesis. /* vim:set foldmethod=indent: */ Case 2: Please look at the comments. Code: window.onload = initAll; // Why no () here? function initAll() { window.doStuff(); // Why () here? } function doStuff() { var msg_text = 'I love you so much!'; var msg_link = window.document.getElementById('msg_link'); console.log(msg_link); var msg_box = window.document.getElementById('msg_box'); msg_link.onmouseover = function() { //msg_box.value = msg_text; msg_box.setAttribute('value', 'May the force be with you!'); }; msg_link.onmouseout = function() { /* This works in ie. */ //msg_box.value = ''; /* Doesn't work in ie7 (and probably not in ie6 either). * Perhaps the code above is reasonable. */ msg_box.removeAttribute('value'); } } /* vim:set foldmethod=indent: */ Hello, very simple code block is below. Javascript functions that call web service methods are working when I called them between form tags. But they are not working at the beginning of the page. I specified lines that are not working below. Please help. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script type="text/javascript"> function GetMyName() { WebService1.GetName(onNameSuccess, onNameFailure); } function onNameSuccess(result) { return result; } function onNameFailure(result) { alert("There is an error"); } function GetMySurname() { WebService1.GetSurname(onSurnameSuccess, onSurnameFailure); } function onSurnameSuccess(result) { return result; } function onSurnameFailure(result) { alert("There is an error"); } //JAVASCRIPT FUNCTIONS ARE NOT WORKING HERE //THESE TWO LINES ARE NOT WORKING var name = GetMyName(); var surname = GetMySurname(); </script> </head> <body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> <Services> <asp:ServiceReference Path="WebService1.asmx" /> </Services> </asp:ScriptManager> //JAVASCRIPT FUNCTIONS ARE WORKING HERE </form> </body> </html> I'm having a spot of trouble in making my functions work and my book seems to be pure rubbish. I'm sure that the error is purely syntax, although it may be something more. Code: <script type="text/javascript" src="flowers.js"></script> <script type="text/javascript"> function pageSetup() { var today = new Date(); // this creates a date object with today's date var banner = displayBanner(today); // *should* call the displayBanner function var days = calcDaysToSale(today); // *should* call the function using today's date document.sale.saleMessage.value = days; // *should* set the value to days. // Obviously none of it works. } </script> This is the code working with the script contained in the html file. I'll post the full page at the bottom. The following code is the JavaScript code. The first function isn't made to provide full functionality at the moment, I'm trying to get the rest of it working. Code: function displayBanner(currentDate) { if (currentDate.getMonth() == 2) imgSrc = "winterLogo"; return ("<img src='" + imgSrc + ".gif'>"); } function calcDaysToSale(currentDate) { var saleDay = new Date(); saleDay.setDate(15); // sets the sale date to the 15th of the current month // Subtracts the days remaining until the sale. // If the number is negative, the sale is over. var Days = saleDay.getDate()-currentDate.getDate(); if (Days < 0) { return "The sale has ended."; } else { return Days; } } I have tried to Google the problem and I have also tried to look it up in my book. I simply don't know the right terms to Google, and as I said the book is rubbish. I don't know why the Code: document.sale.saleMessage.value = days; doesn't work for this. Oh well, I'll learn quickly I suppose. Here is the full HTML code: Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Carol's Flowers</title> <link href="flowers.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="flowers.js"></script> <script type="text/javascript"> function pageSetup() { var today = new Date(); // this creates a date object with today's date var banner = displayBanner(today); // *should* call the displayBanner function var days = calcDaysToSale(today); // *should* call the function using today's date document.sale.saleMessage.value = days; // *should* set the value to days. // Obviously none of it works. } </script> </head> <body class="oneColLiqCtrHdr"> <div id="container"> <div id="header"> <p><img name="myBanner" src="banner" id="myBanner" alt="Carol's Flowers" /> <!-- end #header --> </p> <div id="links"><a href="#">Home</a> | <a href="#">General Arrangements</a> | <a href="#">Seasonal Designs</a> | <a href="#">Custom Orders</a> | <a href="#">Location</a></div> </div> <div id="mainContent"> <table id="mainTable"> <tr> <td width="201"><h1><img src="Flowers.JPG" alt="Random Flowers" width="200" height="255" /></h1></td> <td width="687"> <p>Here at Carol's Flowers, we believe that there is a perfect floral arrangment for every occasion! Take a look around and see if there is anything you like. If we don't already have it, then we will create it for you!</p></td> </script> </tr> </table> <!-- end #mainContent --></div> <div id="footer"> <p> <form name="sale" id="sale"> Days Until Mid Month Madness Sale : <input type="text" name="saleMessage" id="saleMessage" /></form></p> <!-- end #footer --></div> <!-- end #container --></div> <!-- I am trying to run the script here --> <script type="text/javascript"> pageSetup(); </script> </body> </html> This is a little hard to explain so I'm posting an example. Code: //NESTED FUNCTION I'M USING TO DEMONSTRATE MY QUESTION function foo(a) { this.x = 5; //USED TO SET THE VALUE OF X if( a == 0 ) return function(z) { return x = z; } //USED TO RETRIEVE THE VALUE OF X else if( a == 1 ) return function() { return x; } } //MAKES setX THE SETTER FUNCTION var setX = foo(0); //MAKES getX THE GETTER FUNCTION var getX = foo(1); print( "setX(25), not an instance: " + setX( 25 ) ); print( "getX(), not an instance: " + getX() ); print( "" ); //CREATES AN OBJECT INSTANCE USING FOO AS CONSTRUCTOR var q = new foo(); print( "value of x in object instance: " + q.x ); print( "" ); print( "setX(25), not an instance: " + setX( 25 ) ); print( "getX(), not an instance: " + getX() ); This code will output: Code: setX(25), not an instance: 25 getX(), not an instance: 25 value of x in object instance: 5 setX(25), not an instance: 25 getX(), not an instance: 25 Observations: It seems like this.x actually has two meanings. 1)x becomes a member of the "Function" object foo(). 2)x becomes a part of the constructor for prototype class foo. But why then does x revert back to the original value of 5 when I use foo as a constructor? Does javascript automatically save the original value on creation for a reason? What is going on behind the scenes to make this happen? Is this behavior part of an ontological model that makes sense? Similarly, if I change "this.x" to "var x" I can access the value of x but I can't change it. Not that that I should be able to, the syntax "var x" doesn't make x a member of foo anyway. But I'm still having trouble classifying the relationship "var x" has to the function. Anyways this is more of a tangent. My main question is above but if anyone has something to say about this, I'd be interested to hear it. It seems like all these behaviors have rules to them, but there is no conceptual model to think through that guide these behaviors. Or maybe I'm just ignorant. Enlighten me. Hi Everyone I am trying to write some code to create an object in JS that contains the x,y coords for a shape i wish to draw. I create the shape, and then in a draw function I draw the shape to the screen from the object I created erlier. Trouble it is does not seem to work :S have anyone got and ideas? Code: var myShape = new newShape(200,200); function init() { canvas = document.getElementById("canvas"); ctx = canvas.getContext("2d"); return setInterval(draw, 50); } // init function newShape(x,y){ this.un_X=x this.un_Y=y function drawAll() { ctx.beginPath(); ctx.arc(un_X,un_Y,30,0,Math.PI*2,true); ctx.closePath(); ctx.stroke(); } // drawAll } // newShape function draw() { ctx.clearRect(0, 0, WIDTH, HEIGHT); myShape.drawAll(); } // draw init(); Thanks in advance Hello, I'm taking Computer Logic in college. I only am truly familiar with HTML and CSS and minimal web hosting stuff. I REALLY want to learn how to program, however. Anyway, we are doing classes/objects and functions. I am trying to figure out how to do this exercise. She starts with having us make this page that has a form that lets you select one of three radio buttons that will change the background color of the web page, along with that there is two text boxes to put a first name and last name. Then there is a button to click which puts your full name concatenated in another box below. All of this, is done, and I pretty much THINK I understand what is going on. Here is the code that we did to get this to happen: Code: <html> <head> <title>Computer Logic in class</title> <script type="text/javascript"> var nextColor = ""; var BR = "<br />"; function setColor(newColor) { nextColor = newColor; } function changeColor() { document.body.bgColor = nextColor; } function displayName() { var firstName = document.ColorAndText.firstName.value; var lastName = document.ColorAndText.lastName.value; document.ColorAndText.fullName.value = firstName + " " + lastName; } </script> </head> <body bgcolor="red"> <form name="ColorAndText" action = ""> <input type="radio" name="colors" value="Blue" onclick="setColor(this.value)"/> Blue <br /> <input type="radio" name="colors" value="LightYellow" onclick="setColor(this.value)"/> Light Yellow <br /> <input type="radio" name="colors" value="Yellow" onclick="setColor(this.value)"/> Yellow <br /> <input type="button" name="changeButton" value="changeColor" onclick="changeColor()" /> <br /> <input type="text" name="firstName" value="First Name" size="40" /><br /> <input type="text" name="lastName" value="Last Name" size="40" /><br /> <input type="text" name="fullName" readonly="true" size="40" /><br /> <input type="button" name="displayButton" value="Display name" onclick="displayName()" /> <br /> </form> </body> </html> Okay, now, I have and can do that. Seems to make sense. Now, then, the actual program I need to make is from the following exercises: Activity 3-4 The owner of a flower shop wants you to develop a form for use on the shop's web site. The form should have a single text box for the user to enter his or her name. Under the text box should be a group of radio buttons for three different kinds of flowers: Roses, Carnations, and Daisies. Below the radio buttons should be a button labeled Request Info, with a read-only text box under it for thanking the user for requesting information. This program doesn't need any functions or onclick attributes for the graphical elements. Okay, here is the code that does that, very simple HTML. Code: <html> <head> <title>Computer Logic in class</title> <script type="text/javascript"> var nextFlower = ""; var BR = "<br />"; function setFlower(newFlower) { nextFlower = newFlower; } function displayMessage() { var firstName = document.Flowers.nameBox.value; document.Flowers.fullName.value = firstName + "," + nextFlower; } </script> </head> <body bgcolor="white"> <form name="Flowers" action = ""> <input type="text" name="nameBox" value="Namebox" size="60"><br /> <input type="radio" name="flowers" value="Roses" onclick="setFlower(this.value)"/> Roses <br /> <input type="radio" name="flowers" value="Carnations" onclick="setFlower(this.value)"/> Carnations <br /> <input type="radio" name="flowers" value="Daisies" onclick="setFlower(this.value)"/> Daisies <br /> <input type="button" name="displayButton" value="Request Info" onclick="displayMessage(this.value)" /> <br /><br /> <input type="text" name="thankyou" readonly="true" size="100" value="Thanks for using this program" /> </form> </body> </html> Okay, now is where I'm stuck. The following exercise is as follows: The flower shop owner in the previous activity wants to see where you can make the form interactive and asks you to have the form display a message in the bottom text box that includes the user's name, a comma, and the words "thank you for your inquiry about" followed by the flower name the user selected. Write a function named displayMessage() that accesses the user's name from the first text box and displays the message in the read-only text box. You also need to make the Request Info button call the displayMessage() function when it's clicked. Using Javascript, make this form active by including event triggers and functions. My teacher has said that I should be able to do this by just referencing these two previous pages of code that I have already pasted. I feel like I am missing something, that I need to be doing something and it's just not working for me. I'm actually really really stuck on this. I haven't even gotten to the second half of the exercise (where I have to have it display about what flower you select) because I cant get this function to work. What am I missing? Also, the exercise we did before these two had us make a very basic account class and object. We don't have to do that at all in this anywhere, but I do know how to do it, in case I need to make a class or something. ANY AND ALL HELP GREATLY APPRECIATED!!! I just don't know what I'm supposed to do, I can't get it to work. I wrote a log function that took note of various function calls. Thinking that functions are first class objects, and objects have properties, I made the name of each logged function a property of that function, e.g., brightenInnerPara.name = "brightenInnerPara"; Every browser I tried (Firefox, MSIE, Opera, Chrome, Safari) accepted the assignment, no problem. In Firefox and MSIE, the result was what I wanted: brightenInnerPara.name == "brightenInnerPara" But in the others, the result was: brightenInnerPara.name == null Question 1. Which Javascript is correct here? I favor Firefox and MSIE, not merely because they were willing to give me what I wanted, but also because it makes no sense to accept an assignment statement without throwing an error and then give it a null semantics, like Chrome, Opera, and Safari did. I found a workaround, using assignments like this: brightenInnerPara.prototype.name = "brightenInnerPara"; To my surprise, that worked in every browser. But I don't know why. It seems that such assignments are enough to cause each function to have its own distinct prototype. Question 2. Just how inefficient is my workaround, and why does it work? Hi, I have written a number of functions designed to return frequency data on 1000 randomly chosen numbers using different math functions for the rounding. I would like to include all of these functions within the wrapper of another function so that only one call is needed to get returns from all of the 'inner' functions. However, while each of the functions works in isolation, the moment I wrap them in another function they stop working. The following code is one of the functions 'frequencyWrapperOne' that has been wrapped in the function 'testWrapper'. A call to testWrapper does nothing. Can anyone see what I'm doing wrong? Code: function testWrapper() { function frequencyWrapperOne() { var numberArrayOne = new Array(0,0,0); for (var i = 0; i < 1000; i = i + 1) { var chosenNumber = Math.floor(Math.random() * 3); if (chosenNumber == 0) { numberArrayOne[0] = numberArrayOne[0] + 1; } if (chosenNumber == 1) { numberArrayOne[1] = numberArrayOne[1] + 1; } if (chosenNumber == 2) { numberArrayOne[2] = numberArrayOne[2] + 1; } } return window.alert(numberArrayOne.join(',')); } } testWrapper(); Thanks. Hi, can anyone tell me... Code: function Obj() { this.recursiveMethod=function () { //...how to invoke Obj.recursiveMethod from here? } } Gus My question is about the following javascript function that converts 15 digit salesforce IDs to 18 digit salesforce IDs. The function was originally posted here. Developer 1 wrote the function: function convertToCaseInsensitiveId(id) { var hash = ''; for (var c = 0; c < 3; c++) { var h = 0; for (var i = 0; i < 5; i++) { var ch = id.charCodeAt(i + c * 5); if (ch >= 65 && ch <= 91) h += Math.pow(2, i); } hash += String.fromCharCode(h > 26 ? h + 48 - 26 : h + 65); } return id + hash; } Developer 2 said: Since the checksum numbers are mapped to AB..YZ012345, 25 gives Z. The following line > hash += String.fromCharCode(h > 26 ? h + 48 - 26 : h + 65); should be > hash += String.fromCharCode(h > 25 ? h + 48 - 26 : h + 65); otherwise 26 would be mapped to opening bracket (ASCII # 91). Which developer's solution is correct? I am building a website and I need to gather some information but I feel that prompts are unappealing. Maybe something like a form but it defines whatever is typed in as a variable?
Do many programmers remember most of the object properties and methods or do they use IDE or references to find those specific objects. I'm starting to learn Javascript and seeing all the different type of objects available can be depressing. I currently have the following code: <script> function strstr (haystack, needle, bool) { var pos1 = 0; haystack += ''; pos1 = haystack.indexOf(needle); if (pos1 == -1) { return false; } else{ if (bool){ return haystack.substr(0, pos1); } else{ amp1 = haystack.indexOf('&'); if((amp1 == -1) || pos1<amp1){ alert("here"); return haystack.slice(pos1); }else{ bString = haystack.slice( pos1 ); pos2 = bString.indexOf( needle ); amp2 = bString.indexOf('&'); //alert(bString.slice( pos2)); return bString.slice( pos2 ); }//if(amp>1){ }//if (bool){ }//if (pos == -1) { }//function strstr var story = strstr(top.location.href, "story="); var pinID = story.replace("story=", ""); alert(pinID); if(pinID>0){ document.getElementById('iFrame').src = 'http://www.domain.net/index.php?story='+pinID; }//if(pinID>0){ </script> It takes the website URL in Javascript and I wanted it to see if there is a "story=1" id and then pass it to the IFRAME. This works in a fashion, but i was trying to make it into a function so I could find and pass other variables, but anything after an & sign and it all fails? I was hoping to pick out variables from the top.location.ahref of "http://www.domain.com/index.php?story=1&category=2&something=3" for example? Any help would be appreciated. Many thanks Okay so I'm trying to come up with as many alternative methods to accomplish something. So I'm just seeking input from anyone who is willing to supply some. After the user clicks on a match type it'll know HOW MANY sides to the match there are so say for a singles match it'd have 2 sides (1 vs. 1) for a Triple Threat Match it'd have 3 sides (1 vs. 1 vs. 1) and so on. All matches have a stored field in the database of how many sides they have. So I'm thinking that I could have it create 3 divs (or something) down in the competitors area of how many sides there are in the match (separated by a VS. text block) and when the user selects a character from the dropdown and adds a character the user can maybe drag and drop the character's name to whatever side they choose. Its one idea. If you think of an EASIER more EFFICIENT way to do something like this and have an idea say something please or even if you can't let me know that you think it's a worth while idea. Code: <label for="matchtypedrop<?php echo $i+1 ?>">Match Type:</label> <select class="dropdown" name="matchtypedrop<?php echo $i+1 ?>" id="matchtypedrop<?php echo $i+1 ?>" title="Match Type <?php echo $i+1 ?>"> <option value="0">- Select -</option> <?php $query = 'SELECT id, matchtype FROM matchtypes'; $result = mysqli_query ( $dbc, $query ); // Run The Query while ( $row = mysqli_fetch_array ( $result, MYSQL_ASSOC ) ) { print "<option value=\"".$row['id']."\">".$row['matchtype']."</option>\r"; } ?> </select> <label for="competitors<?php echo $i+1 ?>">Competitors:</label><ul id="competitors<?php echo $i+1 ?>" style="list-style: none; margin-left: 195px;"></ul> <select class="dropdown" name="charactersdrop<?php echo $i+1 ?>" id="charactersdrop<?php echo $i+1 ?>" title="Characters Dropdown <?php echo $i+1 ?>" style="margin-left: 195px;"> <option value="0">- Select -</option> <?php $query = 'SELECT id, `character` FROM characters ORDER BY `character`'; $result = mysqli_query ( $dbc, $query ); // Run The Query while ( $row = mysqli_fetch_array ( $result, MYSQL_ASSOC ) ) { print "<option value=\"".$row['id']."\">".$row['character']."</option>\r"; } ?> </select> <input type="button" value="Add Character" class="" onclick="Competitors(<?php echo $i+1 ?>)"/> Hi everybody! I've a problem and I'm not able to solve it alone. I want to invoke java methods of a self written java programm with javascript. I found something like a tutorial (http://stanislavvitvitskiy.blogspot....lications.html), but it has not worked. I put my class file in a jar file and when I want to load it in javascript i get an error. I tried it this way: var url = new java.net.URL('C:/java_js' + '/xultest.jar'); var cl = new java.net.URLClassLoader(url); var aClass = java.lang.Class.forName("com.stan.XULDemo", true, cl); var inst = aClass.newInstance(); // Calling 'sum' function from java var a = inst.sum(2, 3); alert(a); // Will alert '5' Can anyone please help, and say to me what's wrong about it? Or does anyone have another aproach to call java methods with javascript? cheers, Martin Hi all! I'm pretty new to JavaScript and completely new to this forum. I'm James. Well uh, I'm not sure how to... I wanted to make something like this using javascript... Code: myObject.someMethod('something').anotherProperty much like the Code: document.getElementById('someId').style.morestuff But the thing is, I've been around every DOM whatnot I can find, I just can't seem to make it work. I kinda need it to make my own DOM for some API i'm writing. So I can write like... Code: function someGreatAPI(){ this.property1=''; this.property2=''; //... this.method1 = function(var1){ //this should make my firstMethod this.nestedProperty = 0; this.nestedMethod = someFunction; //firstMethods nested method } } //so I can use it like... var obj = new someGreatAPI(); obj.method1(10).nestedMethod(); It has to be possible, it's possible with document.getelementbyid, right? it has to be. Thanks in advance. Hello all. I have a script to prompt a user for 4 pieces of information. First name. Last name Area code. & Telephone number. My assignment was to do this, and put the information is as follows. If both, first name & last name are entered, store in object as last name,first name. If only one is entered. display without the comma. Also store telephone number in (XXX) XXX-XXXX format. I was told to use methods to do all of these things. Please take note I am in a VERY basic javascript class. Thanks in advance. CODE I HAVE SO FAR : head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <script type="text/javascript"> last=name=area=num=''; function info ( ) { last = prompt("Please enter your last name",''); name = prompt("Please enter your first name",''); area = prompt("Please enter your area code",''); num = prompt("Please enter your phone number",''); }; function Person (info) { this.name = name this.last = last this.area = area this.num = num } </script> <title></title> </head> <body> <script type="text/javascript"> info ( ); teacher = new Person(); tempString=''; document.writeln ( last ); document.writeln ( name) ; if(area==''||num==''){tempString='';} else{tempString = teacher.area +''+ teacher.num} document.writeln ( tempString); </script> I am trying to create a function that takes a users input in the form xx/xx/xxxx. Then I need to figure out a way to compare to a new date and give which day of the year it is when using: alert("This is the" +foo+ "day of the year."). Im alittle confused on how to take the users input and compare it somehow to give me the day of the year.
Ok, from the beginning. I have written a HTML5 player with controls and stuff. But I have one problem. After using switch-to-HD option the controls (like full screen) stops working. And in Firebug I see strange behaviour when switching back from HD (press HD, let it load and press HD again) - it seem like every event is triggered two times, and then more and more. What can I do with all of it? And it seems that there is a 'ghost' of the player that was before, cause it still plays when I switch to HD. The player is he http://secondgate.pl/temporary/nttp/ I also tried differend method for switching the source, using .load(). But it seems that Firefox can't load the movie after that and Chrome sets the volume to 100%, so it didn't work either. The player from this method is he http://secondgate.pl/temporary/tpp_004/ I would be mostly grateful for help. I know it's a lot of code, but it's all commented. I have no idea what am I doing wrong and I'm sitting like a week in front of it. |