JavaScript - More Help Needed With Some Javascript
Pretty pretty please help me with this I am running out of time and pulling my hair out with this whole thing.
Thanks a million in advance! Rhonda <!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>Untitled Document</title> <script> function numberGuess() { stringVar=prompt("Enter your guess number"); while (stringVar<999) { } } </script> <script> function enterNames() { stringVar=prompt("Enter name"); } </script> <script> function enterProducts() { stringVar=prompt("Enter product name"); return } </script> </head> <body> <p> </p> <h1>WDV221 Intro Javascript</h1> <h3 align="center">Javascript Loops</h3> <p>Topics: loops, for loops, while loops, sentinels!</p> <p>Place all script code on this page.</p> <p>1. Create a function that will ask you for a number until you enter 999 which will end the loop. You do not need to display the number. </p> <p>2. Create a function that will ask you for a name until you tell the function that you do not have any more names. After you enter each name it will ask you if you have more names to enter. If you enter yes the process will continue. Display each name at the end of the following sentence.</p> <p>The name you entered is: </p> <p>3. Create a runtime script that will use a prompt( ) to accept how many products will be displayed. Use a for loop to display "Product Name" and the product number as a <p> element.</p> <p><strong>Example output:</strong></p> <p>Product Name 1</p> <p>Product Name 2</p> <p>...</p> <p>4. Create a runtime script that will use a nested for loop to create a table with 3 rows and 5 cells. Place the same number or a letter in each cell. </p> <p>Hint: Write a table in HTML. Do a row first then do multiple rows. </p> <p>5. Create a function called totalSales( ) that will ask the user to enter an amount until you enter "done". Add those amounts together and display them in an alert when the user is done entering amounts..</p> <p>Have fun!!</p> </body> </html> Similar Tutorialsnew to JavaScript, simple question... question: how do i determine an output from a prompt to be bold? e.g. a user enters "hello" and the output printed from the prompt becomes bold one=parseFloat(prompt('enter number',0.bold)); I have a script that works good, but it says undefined underneath, this must mean an error. But I cant work out how to get rid of it. This is the html it is a transistional XHTML doc type. Code: <div id="slidedom"> <script type="text/javascript" src="js-files/slider.js"></div></script> Then I have the js file which I will have to post all of as I am not sure of the error bit. Code: var variableslide=new Array() //variableslide[x]=["path to image", "OPTIONAL link for image", "OPTIONAL text description (supports HTML tags)"] variableslide[0]=['images/sign-1.gif'] variableslide[1]=['images/sign-3.gif'] variableslide[2]=['images/sign-4.gif'] //configure the below 3 variables to set the dimension/background color of the slideshow var slidewidth='188px' //set to width of LARGEST image in your slideshow var slideheight='60px' //set to height of LARGEST iamge in your slideshow, plus any text description var slidebgcolor='#FFF' //configure the below variable to determine the delay between image rotations (in miliseconds) var slidedelay=3000 ////Do not edit pass this line//////////////// var ie=document.all var dom=document.getElementById for (i=0;i<variableslide.length;i++){ var cacheimage=new Image() cacheimage.src=variableslide[i][0] } var currentslide=0 function rotateimages(){ contentcontainer='<center>' if (variableslide[currentslide][1]!="") contentcontainer+='<a href="'+variableslide[currentslide][1]+'">' contentcontainer+='<img src="'+variableslide[currentslide][0]+'" border="0" vspace="3">' if (variableslide[currentslide][1]!="") contentcontainer+='</a>' contentcontainer+='</center>' if (variableslide[currentslide][2]!="") contentcontainer+=variableslide[currentslide][2] if (document.layers){ crossrotateobj.document.write(contentcontainer) crossrotateobj.document.close() } else if (ie||dom) crossrotateobj.innerHTML=contentcontainer if (currentslide==variableslide.length-1) currentslide=0 else currentslide++ setTimeout("rotateimages()",slidedelay) } if (ie||dom) document.write('<div id="slidedom" style="width:'+slidewidth+';height:'+slideheight+'; background-color:'+slidebgcolor+'"></div>') function start_slider(){ crossrotateobj=dom? document.getElementById("slidedom") : ie? document.all.slidedom : document.slidensmain.document.slidenssub if (document.layers) document.slidensmain.visibility="show" rotateimages() } if (ie||dom) start_slider() else if (document.layers) window.onload=start_slider I have taken out the credit, as I have changed it a bit, but will reinstate it later on. All I really need to know is how to define it in the XHTML maybe. Can anyone help? I'm working very hard to create a dynamic web-site for use in the education sector using server-side php/MySQL and client-side HTML with javascript. I have a logon page (index.php) which looks to see if the cookie 'mylogon' is set with the value 'Again'. This cookie is set when the PHP element on the server detects an invalid username/password combination. If so I have a javascript function (see below) call from the HTML <body onload="check_invalid_user()"> I know that the function Get_Cookie is working ok and that the javascript variable 'again' has the value 'Again' in it and has a length of 5. The alert function is not executed though. function check_invalid_user() { again = Get_Cookie('mylogon'); // document.write(again); // document.write(again.length); If (again == 'Again') { alert("User-id and/or password incorrect -- Please re-enter"); } } ============= Any help would be appreciated Many thanks in advance. (Yeah you guessed it I'm new and raw to this stuff. How to create a popup blocker with javascript? I am looking for solution to open Enquiry form [Ex: send-query.php] through javascript linking. How can I do that? And how to display a popup blocker message like in the attached file? This is the url of my pop up image: http://www.rhapsody.com/thompson-squ...mpson-square-2 [When you click on play button then if you have popup blocker enabled you will get popup blocker message from the site] Hi, At www.happydaysremovals.com.estimatenew.html. Users fill in a form which has items of furniture, so they enter a number next to each item of furniture. The HTML uses text fields. When the form is submitted, the form is submitted to a php script that emails the results to myself. I am trying to also have a javascript function which runs before the php script runs. This javascript works out the cubic footage of all the items. If a user put "3" in the sofa text field, and I have defined that a sofa is 45 cubic feet, then the javascript will multiply 3 * 45. It will do a similar thing for all items of furniture, then add them all up to give a total cubic feet. I want that total field to then sent as a variable to the php script, along with all the other variables. My code so far (which doesnt work) Code: <script language="JavaScript"> function calculate() { var sofa_3_seater = document.getElementById('sofa_3_seater').value*45; var sofa_2_seater = document.getElementByID('sofa_2_seater').value*30; var armchair_large = document.getElementByID('armchair_large').value*15; var total=sofa_3_seater+sofa_2_seater+armchair_large; document.getElementByID('total').value = total; } </script> I have used a hidden field for the total value: Code: <input type="hidden" name="total" value=""> I want the javascript result to change the value of the hidden field that is called total. THen I want it all to be posted to the PHP script and email everything to me, including this newly calculated total field! THanks I will be completely up front about this, its school work. At the end of a basic html class I missed several classes for family reasons and missed just about everything on Javascript. The book we used basically didnt cover anything over it, was all in class learning I missed. Anyone who could help would be so helpful. One function is partial, one is blank, thats what is supposed to be added/corrected to the following code Code: <html> <head> <script language="javascript" type="text/javascript"> function processScore() { var score = 0; if ( ...checked) {score = score + 1;} if (...checked) {score = score + 1;} document.answerForm.score.value = score; // Display the correct answers document.answerForm.answer1.value = " "; // put the correct value here document.answerForm.answer2.value = " "; // put the correct value here } //End of function processScore function clearForm() { // using the a javascript method clear all forms } </script> </head> <body style="font-family:tahoma; font-size:15px; line-height:200%; width:80%; margin-left:auto; margin-right:auto;"> <hr color="red" width="60%" size="5"> <form name="question1" id="question1"> 1. Which of the following is the document considered to be?<br/> <input type = "radio" name="choiceRB"> a. object<br /> <input type = "radio" name="choiceRB"> b. property<br /> <input type = "radio" name="choiceRB"> c. method<br /> </form> <hr color="green" width="60%" size="5"> <form name="question2" id="question2"> 2. Which method of the window can be used to display a message to the user?<br/> <input type = "radio" name="choiceRB"> a. display()<br /> <input type = "radio" name="choiceRB"> b. message()<br /> <input type = "radio" name="choiceRB"> c. alert()<br /> </form> <hr color="red" width="60%" size="5"> <input type="button" value="Grade the Quiz" onclick=?> <input type="button" value="Start Over" onclick=?> <form name="answerForm" id="answerForm"> <p><strong>Correct Answers:</strong><br/></p> Question 1: <input type="text" name="answer1" size="1"><br /> Question 2: <input type="text" name="answer2" size="1"><br /> <p>You scored <input type="text" name="score" size = "1"> out of 2</p> </form> <br /> </body> </html> thnx in advance to anyone who can help I have a vendor delivered java script code that I am currently customizing. The original code involves a user when selects a "check box" option value , a small function is called titled "VerifyAcctType". Currently when a user selects the check box some values are defaulted into the form. Now to this function code below i have to add logic when user selects the same check box option FIRST a small pop up window should appear which lists two radio buttons"I Agree to terms" and "I do not agree to terms" options , user need to select one of the options in the pop up to proceed. If the user agrees to terms then the control should go back to the "VerifyAcctType" function and proceed with remaining steps like before else if the user selects "I do not agree" the logic should not proceed further in "VerifyAcctType" function. Here is the current code tied to VerifyAcctType function ============================================== function VerifyAcctType(win,type) { var AcctType var ThisWindow var ThisForm if (win == "ADD") { ThisWindow = AddAccountWind ThisForm = AddAccountWind.document.addform } else if (win == "CHG") { ThisWindow = ChangeAccountWind ThisForm = ChangeAccountWind.document.chgform } if (type == "P") { <<I NEED NEW CODE HERE FOR THE POPUP>> Maccttype = type ThisForm.description.value = "My Company" ThisForm.comp_id.value = "1234567" ThisForm.comp_id.disabled = true } else { Maccttype = type ThisForm.description.value = "" ThisForm.comp_id.value = "" ThisForm.comp_id.disabled = false } } I am a java script beginner , any help is appreciated. Hi, I'm trying to get my head around JS, but not too successfully yet. My objective is probably simple (but not to me ): to have a form where visitors enter 12 separate digits (ideally in minutes & hours, but am happy to use decimals), and the average of these (to two decimal points) is returned as document.write is it? - along with other text, to make a complete & coherent sentence, including the average of the 12 numbers. Does anyone have any code convenient that could do this? Thanks, LJ I'm not a coder myself but I could use some help and am willing to pay if it's within reason. It's for a site I'm putting together for a hobby of mine. Here's a description of what I need done: http://masterengraver.com/ambigrams/test.html Please drop me an email with price for your time if you can do this. Thanks! / ~Sam Please see the below code. Is it possible for me to type in an order date in the browser & in the due date field, have it automatically populate a date 7 days greater than the date typed in the order date field? If so how? I have read I will probably need javascript to do this but have no clue where to start. Thanks for any help provided! <html> <head> <title> Update Database </title> </head> <body> <form method="post" action="add.php"> <b>First Name:</b> <br /> <input type="text" name="customer_fname" size="35" /><br /> <b>Last Name:</b> <br /> <input type="text" name="customer_lname" size="35" /><br /> <b>Location:</b> <br /> <input type="text" name="location" size="35" /><br /> <b>Order Date:</b> <br /> <input type="text" name="order_date" size="35" /><br /> <b>Due Date:</b> <br /> <input type="text" name="due_date" size="35" /><br /> <input type="submit" value="Submit" /> </form> </body> </html> Hello everyone, i desperatly need a script for my website but am totally stuck, I hope someone can help On my website i want a search box. I want it so that if a use types in one of my predetermined search terms then they would be sent to a predeterimed page in my own website. For example: I have a group of 5 keywords - nokia, mobile, vodafone, cellphone, iphone. If a user types any of those keywords into my search box then xxxxx.com/mobilephones.htm will be loaded up I have another set of 5 keywords - cat, dog, rabbit, mouse, snake. If a user types any of those into the search box then they are directed to xxxxx.com/animals.htm and so on ... So as you can see, its not a 'normal' search engine I will be creating new pages and will need to add the chosen keywords for it as time goes on etc Nearly everywhere i look for something to help me all I can find are standard search engine scripts which are no good as they display search results instead of directing to specific urls depending on the keywords entered I would also need to 'capture' what search terms are being entered so that I can build some user statistics I understand html and javacript to an intermediate level Can anyone help / provide a script that I could use? Although Im a student Im willing to pay some funds to anyone that can do this for me Many thanks Terry I tried to write the variable my_var into a text file but it only shows null after executing the code. Can anybody help pls?? Below is my code <html> <head> <script language="javascript"> var my_var function WriteToFile() { my_var = 123; document.write(<?php $file="file.txt"; $fh = fopen($file, 'w') or die("can't open file"); ?>; document.write(<?php $stringData = my_var ?>; document.write(<?php fwrite($fh, $stringData); ?>; document.write(<?php fclose($fh); ?>; } </script> </head> <body onLoad="WriteToFile();"> <p>Hello World</p> </body> </html> I am still learning javascript so forgive me if this question is a bad one, I am making scripts for Greasemonkey for a website I am a part of. One of the developers recently commented out (in the source code) a feature that was available before. It is a Football MMORPG game and it used to show college players 40 times but over the past month he commented out the tag that held the script function. I want to know if i can either A) write a js code that can remove the comment tag in the source code or B) write a code that will just add another tag under that and have that js function that was commented out valid. I tried something but ended up just having that function pasted onto the page instead of having it put into the source to have it read by the rest of the data.. here is what im talking about <TABLE width=800 cellspacing=0> <tr> <td colspan=3 style="FONT-SIZE: 11pt"> <b>Hometown:</b>Fort Hunt, VA<br> <b>Height:</b>6-0<br> <b>Weight:</b>206<br> <!--b>40 Time:</b><if rs("team_id")>0 or bRated then><=formatnumber(rs("forty"),2)><br><end if --> i just want to see if there was any way to just delete the comment out of it so i can get this feature again is all. Any help would be awesome... and sorry for the long post i have this line of code: Code: <a href="#" id="profilelink" name="link2" onClick="viewornot(<?php echo $freechat_id ?>)"><?php echo $freechat_list; ?></a> //call the JS onclick and if OK was click do the message box and send button here then i have my JS: Code: function viewornot(id) { var e = confirm('Do you want to view this profile?'); if (e == true) { window.location.href = "http://www-rainbowcode-net/apps_dev.php/profiles/showprofilepersonal?id="+id; window.location('http://www-rainbowcode-net/apps_dev.php/profiles/showprofilepersonal?id='+id); return true; } else { var e2 = confirm('Do you want to send a message?'); if (e2 == true) { //if ok was clicked send value back?? return e2; } } } on the e2 confirm: if i clicked OK how can i send a value back(so that i know OK was clicked) so that i can then produce the message box and send button and do the rest of the code to send a message??? thank you I have a page with options, and I need to hide options unless a certain choice is selected. So say you have a select box for male and female, if they select male, I need it to show male options, and if they select female, it shows female options. How can I hide things until selected and then show the textboxes and stuff? Thank you! Problem solved thanks to Philip M. ____________________________________________________________________________________ Here is the source code: Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <HTML> <HEAD> <TITLE>Order Forms</TITLE> <SCRIPT> /******************************* Form Calculations ************************************/ function calculate(fld, price) { // fld will equal pw1 or pe1 var dir = fld.name.charAt(1); // used to determine whether it is the East or West Form var num = fld.name.charAt(2); // what Item number is it var quant = fld.options[fld.selectedIndex].value; // how many of the items did the User choose var subtotal = eval(quant * price); // the eval converts a string to an Object property - in this case the value // dir = East or West & num = Item number // with this information we can post the result to appropriate Form & // to the appropriate Field on the Form eval('document.order.t' + dir + num).value = fix(subtotal); var total = 0; // this loop sums the totals for each of the Items to give us the Grand Total for that Form for (i = 1; i < 11; i++) { // does that particular Item have a "total" - in other words did the User choose this Item var itemTotal = eval('document.order.t' + dir + i).value; // total is a running sum of the Form's "subtotals" if (parseFloat(itemTotal) > 0) total += parseFloat(itemTotal); } // prior to sticking in the Grand Total into the Total Field we need to "dollarize" the number eval('document.order.total' + dir ).value = fix(total); } // a number like 6.6 should ultimately read as $6.60 and not $6.6 // a number like 6.6275 should ultimately read as $6.63 // the fix(total) function takes care of these particular problems function fix(total) { // ie, total == 6.6275 var dollars = Math.floor(total); // dollars = 6 // browsers sometimes have rounding errors - 662.75 - 600 = 62.75 var cents = (total * 100) - (dollars * 100); cents = Math.round(cents); // 63 if (cents < 10) cents = "0" + cents; // .998 will become 1.00 so we need to increment the dollar value by one if (cents == 100) dollars++; // if cents equal 0 then dollars equal total or total + 1 incase of .998 if (dollars == total || dollars == Math.floor(total) + 1) cents = "00"; total = dollars + "." + cents; // 6.63 return total; } /******* End of Form Calculations ********/ </SCRIPT> </HEAD> <BODY BGCOLOR="#FFFFFF"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td><form action="sendemail.php" method="post" name="order" id="order" onSubmit="return ValidateInput(this)"></td> <td><input type="hidden" name="Formulaire de commande site Pain et Passion" value=""></td> <td></td> <td></td> </tr> <tr> <td>Product</td> <td>Price</td> <td>Quantity</td> <td>Total</td> </tr> <tr> <td>Item 1</td> <td>1.99</td> <td><SELECT NAME="pw1" SIZE="1" ONCHANGE="calculate(this, 1.99)"> <OPTION VALUE="0">0</OPTION> <OPTION VALUE="1">1</OPTION> <OPTION VALUE="2">2</OPTION> <OPTION VALUE="3">3</OPTION> <OPTION VALUE="4">4</OPTION> <OPTION VALUE="5">5</OPTION> <OPTION VALUE="6">6</OPTION> <OPTION VALUE="7">7</OPTION> <OPTION VALUE="8">8</OPTION> <OPTION VALUE="9">9</OPTION> <OPTION VALUE="10">10</OPTION> <OPTION VALUE="11">11</OPTION> <OPTION VALUE="12">12</OPTION> <OPTION VALUE="13">13</OPTION> <OPTION VALUE="14">14</OPTION> <OPTION VALUE="15">15</OPTION> <OPTION VALUE="16">16</OPTION> <OPTION VALUE="17">17</OPTION> <OPTION VALUE="18">18</OPTION> <OPTION VALUE="19">19</OPTION> <OPTION VALUE="20">20</OPTION> </SELECT></td> <td><INPUT TYPE="text" NAME="tw1" SIZE="10" VALUE></td> </tr> <tr> <td>Item2</td> <td>2.99</td> <td><SELECT NAME="pw2" SIZE="1" ONCHANGE="calculate(this, 2.99)"> <OPTION VALUE="0">0</OPTION> <OPTION VALUE="1">1</OPTION> <OPTION VALUE="2">2</OPTION> <OPTION VALUE="3">3</OPTION> <OPTION VALUE="4">4</OPTION> <OPTION VALUE="5">5</OPTION> <OPTION VALUE="6">6</OPTION> <OPTION VALUE="7">7</OPTION> <OPTION VALUE="8">8</OPTION> <OPTION VALUE="9">9</OPTION> <OPTION VALUE="10">10</OPTION> <OPTION VALUE="11">11</OPTION> <OPTION VALUE="12">12</OPTION> <OPTION VALUE="13">13</OPTION> <OPTION VALUE="14">14</OPTION> <OPTION VALUE="15">15</OPTION> <OPTION VALUE="16">16</OPTION> <OPTION VALUE="17">17</OPTION> <OPTION VALUE="18">18</OPTION> <OPTION VALUE="19">19</OPTION> <OPTION VALUE="20">20</OPTION> </SELECT></td> <td><INPUT TYPE="text" NAME="tw2" SIZE="10" VALUE></td> </tr> <tr> <td>item3</td> <td>3.99</td> <td><SELECT NAME="pw3" SIZE="1" ONCHANGE="calculate(this, 3.99)"> <OPTION VALUE="0">0</OPTION> <OPTION VALUE="1">1</OPTION> <OPTION VALUE="2">2</OPTION> <OPTION VALUE="3">3</OPTION> <OPTION VALUE="4">4</OPTION> <OPTION VALUE="5">5</OPTION> <OPTION VALUE="6">6</OPTION> <OPTION VALUE="7">7</OPTION> <OPTION VALUE="8">8</OPTION> <OPTION VALUE="9">9</OPTION> <OPTION VALUE="10">10</OPTION> <OPTION VALUE="11">11</OPTION> <OPTION VALUE="12">12</OPTION> <OPTION VALUE="13">13</OPTION> <OPTION VALUE="14">14</OPTION> <OPTION VALUE="15">15</OPTION> <OPTION VALUE="16">16</OPTION> <OPTION VALUE="17">17</OPTION> <OPTION VALUE="18">18</OPTION> <OPTION VALUE="19">19</OPTION> <OPTION VALUE="20">20</OPTION> </SELECT></td> <td><INPUT TYPE="text" NAME="tw3" SIZE="10" VALUE></td> </tr> <tr> <td>Item3</td> <td>1.99</td> <td><SELECT NAME="pw4" SIZE="1" ONCHANGE="calculate(this, 1.99)"> <OPTION VALUE="0">0</OPTION> <OPTION VALUE="1">1</OPTION> <OPTION VALUE="2">2</OPTION> <OPTION VALUE="3">3</OPTION> <OPTION VALUE="4">4</OPTION> <OPTION VALUE="5">5</OPTION> <OPTION VALUE="6">6</OPTION> <OPTION VALUE="7">7</OPTION> <OPTION VALUE="8">8</OPTION> <OPTION VALUE="9">9</OPTION> <OPTION VALUE="10">10</OPTION> <OPTION VALUE="11">11</OPTION> <OPTION VALUE="12">12</OPTION> <OPTION VALUE="13">13</OPTION> <OPTION VALUE="14">14</OPTION> <OPTION VALUE="15">15</OPTION> <OPTION VALUE="16">16</OPTION> <OPTION VALUE="17">17</OPTION> <OPTION VALUE="18">18</OPTION> <OPTION VALUE="19">19</OPTION> <OPTION VALUE="20">20</OPTION> </SELECT></td> <td><INPUT TYPE="text" NAME="tw4" SIZE="10" VALUE></td> </tr> <tr> <td>Item4</td> <td>3.99</td> <td><SELECT NAME="pw5" SIZE="1" ONCHANGE="calculate(this, 3.99)"> <OPTION VALUE="0">0</OPTION> <OPTION VALUE="1">1</OPTION> <OPTION VALUE="2">2</OPTION> <OPTION VALUE="3">3</OPTION> <OPTION VALUE="4">4</OPTION> <OPTION VALUE="5">5</OPTION> <OPTION VALUE="6">6</OPTION> <OPTION VALUE="7">7</OPTION> <OPTION VALUE="8">8</OPTION> <OPTION VALUE="9">9</OPTION> <OPTION VALUE="10">10</OPTION> <OPTION VALUE="11">11</OPTION> <OPTION VALUE="12">12</OPTION> <OPTION VALUE="13">13</OPTION> <OPTION VALUE="14">14</OPTION> <OPTION VALUE="15">15</OPTION> <OPTION VALUE="16">16</OPTION> <OPTION VALUE="17">17</OPTION> <OPTION VALUE="18">18</OPTION> <OPTION VALUE="19">19</OPTION> <OPTION VALUE="20">20</OPTION> </SELECT></td> <td><INPUT TYPE="text" NAME="tw5" SIZE="10" VALUE></td> </tr> <tr> <td>Item5</td> <td>2.99</td> <td><SELECT NAME="pw6" SIZE="1" ONCHANGE="calculate(this, 2.99)"> <OPTION VALUE="0">0</OPTION> <OPTION VALUE="1">1</OPTION> <OPTION VALUE="2">2</OPTION> <OPTION VALUE="3">3</OPTION> <OPTION VALUE="4">4</OPTION> <OPTION VALUE="5">5</OPTION> <OPTION VALUE="6">6</OPTION> <OPTION VALUE="7">7</OPTION> <OPTION VALUE="8">8</OPTION> <OPTION VALUE="9">9</OPTION> <OPTION VALUE="10">10</OPTION> <OPTION VALUE="11">11</OPTION> <OPTION VALUE="12">12</OPTION> <OPTION VALUE="13">13</OPTION> <OPTION VALUE="14">14</OPTION> <OPTION VALUE="15">15</OPTION> <OPTION VALUE="16">16</OPTION> <OPTION VALUE="17">17</OPTION> <OPTION VALUE="18">18</OPTION> <OPTION VALUE="19">19</OPTION> <OPTION VALUE="20">20</OPTION> </SELECT></td> <td><INPUT TYPE="text" NAME="tw6" SIZE="10" VALUE></td> </tr> <tr> <td>Item6 </td> <td>4.99</td> <td><SELECT NAME="pw7" SIZE="1" ONCHANGE="calculate(this, 4.99)"> <OPTION VALUE="0">0</OPTION> <OPTION VALUE="1">1</OPTION> <OPTION VALUE="2">2</OPTION> <OPTION VALUE="3">3</OPTION> <OPTION VALUE="4">4</OPTION> <OPTION VALUE="5">5</OPTION> <OPTION VALUE="6">6</OPTION> <OPTION VALUE="7">7</OPTION> <OPTION VALUE="8">8</OPTION> <OPTION VALUE="9">9</OPTION> <OPTION VALUE="10">10</OPTION> <OPTION VALUE="11">11</OPTION> <OPTION VALUE="12">12</OPTION> <OPTION VALUE="13">13</OPTION> <OPTION VALUE="14">14</OPTION> <OPTION VALUE="15">15</OPTION> <OPTION VALUE="16">16</OPTION> <OPTION VALUE="17">17</OPTION> <OPTION VALUE="18">18</OPTION> <OPTION VALUE="19">19</OPTION> <OPTION VALUE="20">20</OPTION> </SELECT></td> <td><INPUT TYPE="text" NAME="tw7" SIZE="10" VALUE></td> </tr> <tr> <td>Item7</td> <td>5.99</td> <td><SELECT NAME="pw8" SIZE="1" ONCHANGE="calculate(this, 5.99)"> <OPTION VALUE="0">0</OPTION> <OPTION VALUE="1">1</OPTION> <OPTION VALUE="2">2</OPTION> <OPTION VALUE="3">3</OPTION> <OPTION VALUE="4">4</OPTION> <OPTION VALUE="5">5</OPTION> <OPTION VALUE="6">6</OPTION> <OPTION VALUE="7">7</OPTION> <OPTION VALUE="8">8</OPTION> <OPTION VALUE="9">9</OPTION> <OPTION VALUE="10">10</OPTION> <OPTION VALUE="11">11</OPTION> <OPTION VALUE="12">12</OPTION> <OPTION VALUE="13">13</OPTION> <OPTION VALUE="14">14</OPTION> <OPTION VALUE="15">15</OPTION> <OPTION VALUE="16">16</OPTION> <OPTION VALUE="17">17</OPTION> <OPTION VALUE="18">18</OPTION> <OPTION VALUE="19">19</OPTION> <OPTION VALUE="20">20</OPTION> </SELECT></td> <td><INPUT TYPE="text" NAME="tw8" SIZE="10" VALUE></td> </tr> <tr> <td>Item8</td> <td>1.99</td> <td><SELECT NAME="pw9" SIZE="1" ONCHANGE="calculate(this, 1.99)"> <OPTION VALUE="0">0</OPTION> <OPTION VALUE="1">1</OPTION> <OPTION VALUE="2">2</OPTION> <OPTION VALUE="3">3</OPTION> <OPTION VALUE="4">4</OPTION> <OPTION VALUE="5">5</OPTION> <OPTION VALUE="6">6</OPTION> <OPTION VALUE="7">7</OPTION> <OPTION VALUE="8">8</OPTION> <OPTION VALUE="9">9</OPTION> <OPTION VALUE="10">10</OPTION> <OPTION VALUE="11">11</OPTION> <OPTION VALUE="12">12</OPTION> <OPTION VALUE="13">13</OPTION> <OPTION VALUE="14">14</OPTION> <OPTION VALUE="15">15</OPTION> <OPTION VALUE="16">16</OPTION> <OPTION VALUE="17">17</OPTION> <OPTION VALUE="18">18</OPTION> <OPTION VALUE="19">19</OPTION> <OPTION VALUE="20">20</OPTION> </SELECT></td> <td><INPUT TYPE="text" NAME="tw9" SIZE="10" VALUE></td> </tr> <tr> <td>Item9 (not working)</td> <td>5.99</td> <td><SELECT NAME="pw10" SIZE="1" ONCHANGE="calculate(this, 5.99)"> <OPTION VALUE="0">0</OPTION> <OPTION VALUE="1">1</OPTION> <OPTION VALUE="2">2</OPTION> <OPTION VALUE="3">3</OPTION> <OPTION VALUE="4">4</OPTION> <OPTION VALUE="5">5</OPTION> <OPTION VALUE="6">6</OPTION> <OPTION VALUE="7">7</OPTION> <OPTION VALUE="8">8</OPTION> <OPTION VALUE="9">9</OPTION> <OPTION VALUE="10">10</OPTION> <OPTION VALUE="11">11</OPTION> <OPTION VALUE="12">12</OPTION> <OPTION VALUE="13">13</OPTION> <OPTION VALUE="14">14</OPTION> <OPTION VALUE="15">15</OPTION> <OPTION VALUE="16">16</OPTION> <OPTION VALUE="17">17</OPTION> <OPTION VALUE="18">18</OPTION> <OPTION VALUE="19">19</OPTION> <OPTION VALUE="20">20</OPTION> </SELECT></td> <td><INPUT TYPE="text" NAME="tw10" SIZE="10" VALUE></td> <tr> <td><p align="right">grand total <img src="arrow.png" width="32" height="32" border="0" alt="" align="absmiddle"></p></td> <td><input type="text" name="totalw" size="10" style="background: #87cefa;"></td> <td align="left"><input type="submit" value="SEND YOUR ORDER" style="background: #87cefa;"></td> </tr> </tr> <tr> <td>Name</td> <td><input type="text" name="name"></td> <td></td> <td></td> </tr> <tr> <td>e-mail</td> <td><input type="text" name="e-mail"></td> <td></td> <td></td> </tr> <tr> <td>Phone</td> <td><input type="text" name="phone"></td> <td></td> <td></td> </tr> </table> </FORM> </BODY> </HTML> Hi, I have a .php page that have a multiple check box question that requires validation whether or not the user checked any values. ----------------------------- HTML: ----------------------------- <p><font color="#FF0000">*</font> If you are a health professional, what is your practice setting (check all that apply):<br> <input name="Q2_PracticeSetting[]" type="checkbox" value="Hospital"> Hospital<br> <input name="Q2_PracticeSetting[]" type="checkbox" value="Outpatient setting"> Outpatient setting<br> <input name="Q2_PracticeSetting[]" type="checkbox" value="Academia"> Academia<br> <input name="Q2_PracticeSetting[]" type="checkbox" value="Research"> Research<br> <input name="Q2_PracticeSetting[]" type="checkbox" value="Other"> Other </p> ----------------------------- Using Javascript: ----------------------------- function ValidateForm() { field = document.register.firstname; if (isBlank(field, "First Name")) return false; field = document.register.lastname; if (isBlank(field, "Last Name")) return false; field = document.register.credential; if (isBlank(field, "Credentials")) return false; field = document.register.email; if (isBlank(field, "Email Address")) return false; if (!isEmail(field, "Email Address")) return false; var chks = document.register.elements['Q2_PracticeSetting[]']; var hasChecked = true; for (var i=0;i<chks.length;i++){ if (chks[i].checked){ hasChecked = false; break; } } if (!hasChecked){ alert("Please select at least one."); chks[0].focus(); return false; } return true; } ----------------------------- Result: ----------------------------- Not working Any help is much apprciated! Hi Coders... I'm building a 'really simple' JavaScript program to help editors write SEO-friendly META titles and META descriptions. The idea is you have 3 text boxes, each on a separate line: BOX 1 - META TITLE [ i.e. "Cool website page" ] BOX 2 - FILE NAME [ i.e. "This is a really cool web page about cool stuff"] BOX 3 - META DESCRIPTION [ i.e. "cool-web-page" ] As the editor types in the boxes, a serp listing is displayed as it would appear on Google (and ideally how it would appear on Bing and Yahoo): Cool website page www.coolwebsite.com/cool-web-page This is a really cool web page about cool stuff Kudos to any one who could point a JavaScript newbie in the right direction can anybody help with these programs, the javascript must be a simple as possible 5 Functions A year six class require a basic calculator for maths class. Create an application that: 1 Allows the user to enter two numbers. 2 Allows user to choose from performing an addition, subtraction, multiplication or division on the numbers. 3 Displays the results on screen. F1VW 34: Client Side Scripting for Web Applications 6 Objects A new web company requires a user input form so clients can sign up for their monthly e-letter. The details required a ♦ name ♦ e-mail address ♦ gender ♦ date of birth ♦ a checkbox to confirm if they wish to be contacted for other marketing purposes The web company also want to save the name of the customer so they have their details in a file. Create an application that: 1 Has a form to take in the required input. 2 Saves the name to a cookie which expires in six months. 3 Validates the input appropriately. 7 DHTML You need to produce a web document about yourself to place in the online year book, adding a picture, and a paragraph about yourself. Create an application that: 1 Allows the user to change the size of text on screen to small, medium or large. 2 Allows the user to change the colour of the screen background. 3 Animates your picture from the top left to the bottom right hand side of screen. Hi, I have got a code here for lottery numbers, it has been asked to matches the draw number and it is not working, a help really needed from any kindness person. I am new to JavaScript, and I have been asked to complete the codes: <html> //Variables //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- var draw = new Array; //Variable to use in Array to store entered draw numbers. var bb=0; //Variable for bonus ball to use in the bonus ball opening slash screen. var vbb=0; //Variable for valid bonus ball to be used in the bonus ball opening slash screen. var c=0; var date = new Date(); //Variable for time and date. //Syndicate numbers in Array //-------------------------------------------------------------------------------------------------------------------------------------------------------------- var set1 = new Array(); //Variable for set 1 syndicate numbers to use in Array. set1[0]=" 3"; //Number to be used in (set1) Array. set1[1]=" 9"; //Number to be used in (set1) Array. set1[2]=" 18"; //Number to be used in (set1) Array. set1[3]=" 27"; //Number to be used in (set1) Array. set1[4]=" 30"; //Number to be used in (set1) Array. set1[5]=" 33"; //Number to be used in (set1) Array. var set2 = new Array(); //Variable for set 2 syndicate numbers to use in Array. set2[0]=" 5"; //Number to be used in (set2) Array. set2[1]=" 7"; //Number to be used in (set2) Array. set2[2]=" 11"; //Number to be used in (set2) Array. set2[3]=" 12"; //Number to be used in (set2) Array. set2[4]=" 34"; //Number to be used in (set2) Array. set2[5]=" 42"; //Number to be used in (set2) Array. var set3 = new Array(); //Variable for set 3 syndicate numbers to use in Array. set3[0]=" 4"; //Number to be used in (set3) Array. set3[1]=" 15"; //Number to be used in (set3) Array. set3[2]=" 21"; //Number to be used in (set3) Array. set3[3]=" 23"; //Number to be used in (set3) Array. set3[4]=" 27"; //Number to be used in (set3) Array. set3[5]=" 31"; //Number to be used in (set3) Array. var syndicates = new Array(); //Variable to use in Array for syndicate numbers. syndicates[0]=set1; //String to use in Array for syndicate numbers. syndicates[1]=set2; //String to use in Array for syndicate numbers. syndicates[2]=set3; //String to use in Array for syndicate numbers. </script> </head> <body> <script> //The Opening ("Splash") screen to ask user for the six numbers and the bonus ball from number 1 to 49 //------------------------------------------------------------------------------------ for (counter=1; counter < 6; counter++) { //Opening brace on new line. do { //Opening brace on new line. dns=window.prompt("Please Enter Draw Number From 1 to 49 : ", counter); if (isNaN(dns) == true) dns=0; } while ((dns < 1) || (dns > 49)); var vd=draw.indexOf(dns); //Local variable to use in entering draw numbers for returning the position of the occurrence of the draw value as a string. if (vd >= 0) //If the value greater than 0, do... . { //Opening brace on new line. alert("Duplicate Number Entered!"); //Alert pop-up. counter--; // } else draw[counter]=dns; } while (vbb < 1) { do { bb=window.prompt("Please Enter Bonus Ball From 1 to 49 : ", counter); if (isNaN(bb) == true) bb=0; } while ((bb < 1) || (bb > 49)); var vd=draw.indexOf(bb); //Local variable to use in entering the bonus ball for returning the position of the occurrence of the bonus ball value as a string. if (vd >= 0) alert("Duplicate Number Entered!"); else vbb=1; } //Background colour and to display title, time and date //---------------------------------------------------------------------------------------------------------------------------------- document.body.style.background = "#FFB6C1"; document.write("<h2><u><p align=center>Lottery Number Checker</p></u></h2>"); document.write("<b>Time: </b>"); document.write(date.getHours()); document.write("."); document.write((date.getMinutes())); document.write("<br><b> Date: </b>"); document.write(date.getDate()); document.write("."); document.write(date.getMonth() + 1); document.write("."); document.write((date.getFullYear()), "<br><br><br>"); //Entered numbers, draw numbers, bonus ball, number of matches //---------------------------------------------------------------------------------------------------------------------------- document.write("<b>The numbers you have entered for the draw and bonus ball a </b>",(draw),", ",(bb),".<br><br><br>"); document.write("<b>Draw numbers from set 1 a </b>",(set1),"<br>"); document.write("<b>Draw numbers from set 2 a </b>",(set2),"<br>"); document.write("<b>Draw numbers from set 3 a </b>",(set3),"<br><br><br>"); displaymatches(); document.write("<br><br>"); document.write((bbcheck()),"<br><br><br>"); //Function to check draw and bonus ball against entries numbers //----------------------------------------------------------------------------------------------------------------------------------------------------- function drawcheck(dnums) { for (a=0; a < 6; a++) for (b=c; b < 6; b++) if (syndicates[a]=draw[b]); { document.write(dnums[a]," "); c=b; } } //Function for syndicate numbers hit //-------------------------------------------------------------------------------------------------------------------------------------------------- function hits(dnums) { for (d=0; d < 6; d++) for (e=c; e < 6; e++) if (syndicates[d] == draw[e]) { noh++; c=e; } return noh; } //Function to display matches//-------------------------------------------------------------------------------------------------------------------------------------------------- function displaymatches() { var times=syndicates.length; for (f=0; f < times; f++) { if (noh > 0) { document.write("<b>The number of hits for set ",f+1," is: </b>",noh,"<br>"); document.write("<b>Matching numbers for set ",f+1," are : </b>"); drawcheck(syndicates[f]); } else document.write("No hits for set ",f+1," this time <br>"); for (g=0; g < 6; g++) if (bb == syndicates[f][g]) document.write("<b><font color=blue>Matchig bonusball is: </b>",bb,"</font><br>"); document.write("<br><br>"); } } </script> </body> </html> |