JavaScript - Looping With For Var Command
Hi,
I have this code.. Code: javascript:function showMore() {ProfileStream.getInstance().showMore(); setTimeout(showMore, 2000)}; showMore(); i want to loop it 10 times, but do not know how to do it. I have been told that the for var command is what I want, but I cannot get it to work. Any help would be appreciated. Thanks Similar TutorialsSorry for the stupid question but i can't find a specific answer and i'm a newby. Here is a example of what i have: <html> <head> <script type="text/javascript"> function open_win() {window.open("http://www.microsoft.com","Window1","menubar=no,width=660,height=300,toolbar=no,scrollbars=yes");} </script> </head> <body> <form> <input type=button value="Open Window" onclick="open_win()"> </form> </body> In stead of a button to open one window, i would like a numeric input box that asks "How many windows do you want to open?" then incorporate a loop command to loop the open_win() x amount of times. Any help would be appreciated. Thanks I am trying to use the LPR command inside a javascript to print a PDF file directly to the printer. Want just a simple webpage with a button which will print test.pdf when clicked. lpr -S xxx.xxx.xxx.xxx -P print -o l C:\Users\xxxxxx\Desktop\test.pdf I know very little when it comes to javascript. If you know of a better way to use the lpr command, please let me know. I need to set something up so every X amount of second on a page it goes a certain command, and keeps resetting the counter after everytime and goes again. I thought of many of the timer commands I have found on Google but didn't know if this was the RIGHT way to do it since I want it to be a document command that repeats. If what is returned to the command is true instead of false it needs to be able to change location of the browser, so I didn't know if the timer commands I found were right or not. Thanks. How to set a js command using a variable? var name = 'field'; var number = '1'; name.number(); doesn't work [when the js function is called field1] I am using a set of dynamically created textareas and need to be able to reference each one by number. Any thoughts? hey everyone, I am having some trouble with one of my buttons, the one button works fine but my second one doesnt work at all. The second button should open the same page as the first and maximize it. Could someone please help me with this? Thanks. Code: <html> <head> <title>commands</title> <script type="text/javascript"> /* <![CDATA[ */ var maxWindow function createWindow() { var winWidth=300; var winHeight=100; var winLeft = (screen.width-winWidth)/2; var winTop = (screen.height-winHeight)/2; var winOptions = ",width=" + winWidth; winOptions += ",height=" + winHeight; winOptions += ",left=" + winLeft; winOptions += ",top=" + winTop; maxWindow = window.open("MaxWindow.html", "newWindow", winOptions); maxWindow.focus(); } function maximizeWindow() { maxWindow.moveTo(0,0); maxWindow.resizeTo(screen.availWidth,screen.availHeight); maxWindow.focus(); } /* ]]> */ </script> </head> <body> <input type="button" name="Create New Window" value="Create new Window" onclick="createWindow();"/> <input type="button" name="Maximize New Window" value="Maximize New Window" onclick="maximizeWindow();"/> </body> </html> I am modifying a small online text editor. I have a series of dynamically generated fields: sub0 sub1 sub2 etc. I get stuck feeding the modified data back. subX.selection.setContent() - where X is the field number. how can I set X as a variable? For example, how can I write "Hello!" on the page every Friday at 8:40?
im not sure now to word it, or how to do it, im a php coder not a javascript -.- but here it is, basicly i have one ajax file and wish to use it for everypage, i tryed to do it so i can just call one function for all ajax uses, but forms seem to be thowing me off the idea is when i call it, i stat if its a form or a element, Code: function ajax(str, b, c) { a = b; type = c; if (type === 'form') { document.form.b.value='Reading in progress...'; } if (type === 'element') { document.getElementById(a).innerHTML='Reading in progress...'; } xmlhttp = GetXmlHttpObject(); if (xmlhttp === null) { alert('Your browser does not support XMLHTTP!'); return; } xmlhttp.onreadystatechange = stateChanged; xmlhttp.open('GET', str, true); xmlhttp.send(null); } in this, the variable a is set as the id of the elemnt/form, it works fine for elemnts, but not for forms, i think this is because its thinking a is the id, not the variable, any way around this? Hi, I've ben trying to figure this one out for days now and so I'd thought to give it a shoot here to see whether anybody can give me any advice or inspiration. Basically what I am trying to do is command a click of a bottom for a certain set time. for example: On the google main search engine page. Once ive typed in a search for "skateboards". I would then like to command the "search" bottom to clicked at 10 pm at night thus executing the search for "skateboards" going into the next page with all the search results. I was wondering if it would be possible to right a Java command that could be run in the Mozilla Fire Fox Scratch pad tool. ( Which is found under Tools --> Web Developer.) Please let me know of anything. It would be very grateful. Thanks, Jon57 I'm a newby that just finished an online javascript course. When I do a search on Math.random() I receive sites that all describe the command as returning a number 'between 0 and 1'. My question is - are the expected numbers limited to - 0.0000000000000001 thru 0.9999999999999999 or is it possible to get the 0 and 1 also. Seems like the definition should be 'from 0 thru 1' rather than 'between 0 and 1'. JoeF I am trying to run a stored proc from my page using JScript and I am stuck on this error: Quote: Microsoft OLE DB Provider for ODBC Drivers error '80040e14' [Microsoft][ODBC SQL Server Driver][SQL Server]Procedure or Function 'AD_AdminInsert2' expects parameter '@CourseID', which was not supplied. The param @CourseID is requested in the stored proc but I don't know why it is not finding it from the following code: Code: cmdAdminInsert = Server.CreateObject("ADODB.Command"); cmdAdminInsert.ActiveConnection = connStringforTest; cmdAdminInsert.CommandText = "dbo.AD_AdminInsert2"; cmdAdminInsert.CommandType = adCmdStoredProc; cmdAdminInsert.Parameters.Append(cmdAdminInsert.CreateParameter ("RETURN_VALUE", adInteger, adParamReturnValue)); cmdAdminInsert.Parameters.Append(cmdAdminInsert.CreateParameter ("@CallerAdminID", adInteger, adParamInput, 1709)); cmdAdminInsert.Parameters.Append(cmdAdminInsert.CreateParameter ("@CourseID", adInteger, adParamInput, 65)); cmdAdminInsert.Parameters.Append(cmdAdminInsert.CreateParameter ("@AdminID", adInteger, adParamOutput)); cmdAdminInsert.Parameters.Append(cmdAdminInsert.CreateParameter ("@OutputResult", adVarChar, adParamOutput, 255)); cmdAdminInsert.Execute(); cmdAdminInsert.ActiveConnection.Close(); An insight or links would be appreciated. Thanks, JJ hi, i am trying to make my website so that when i click on a button it makes the selected text into bold or when i click another button it makes the selected text italic and finally when a thrid button is clicked it makes it underlined. i have tried searching for a way of doing this throught javascript but i cant seem to find any. any suggestions or examples on how i can achieve this would be much appreciated as i really need to get this working, thanks for any advice given Very naive coding question... i'm a novice coder and i think javascript is the solution i need but - maybe there's better ways... Ok - my website accepts a login password to access certain pages. Depending on the password entered i set a javascript variable to either 'true' or 'false'. If the variable is set to 'true' then i want to give the user access to shopping cart buttons, if 'false' then the shopping cart buttons should be hidden. My current solution is to wrap javascript around each shopping cart button and display only if the variable is set to 'true'. The shopping cart button looks a bit like this: Code: <form method="post" action="http://www.shoppingcart.com"> <input type="hidden" name="product" value="product" /> <input type="hidden" name="price" value="9.99" /> <input type="hidden" name="return" value="http://www.home.com"/> <input type="submit" value="add to basket" /> </form> I've tried displaying this using document.write() - but it gets confused when it encounters the ":" in the web address. Also i get the impression from trawling the forums that document.write is not flavour of the month these days. And another thought - I accept the variable on one page - then move to multiple other pages to reference it.... will the variable still be there when i move to other pages or do i need to somehow pass it across each time? Trying to keep my coding XHTML compliant... Any pointers and idiot proof suggestions would be much appreciated. So im working on a case where I need to make a random ad pop up every time I refresh that web page. I've got all the steps down except to where I need to insert a command to write the text to the document. *Insert a command to write the following text to the Web document: Code: <a href="URL"> <img src="adn.jpg" alt="description" /> </a> where URL is the value of the rLink variable, n is the value of the rNumber variable, and description is the value of the rAD variable. what I have so far (all steps completed) is Code: <script type="text/javascript"> var rNumber= randInt(5);// generate a random integer from 1 to 5. var rAd= adDescription(rNumber);// description of the random ad. var rLink= adLink(rNumber);// URL of the random ad. document.write('<a href'"+rLink+"'><img src="ad'+rNumber+'.jpg" alt="'+rAd+'"/></a>'); </script> the bolded is the question, I know some quotes are out of order but I cant figure out which. any help would be appreciated I need to loop through an array like this one: [1,2,4,8,8,16,32,64] I don't really know how to do this, so a little guidance would be great. Basically, I have 4 vars: a b c and d in the form of (ax + b)(cx + d) inside the loop something like this: i++ a = array[i] If (a*b > Math.floor(a) && a*b < Math.ceil(a)){ then increment i again and do the loop again} else{ break the loop and set leave a = array[i] } A code sample or something would be really nice (I don't know how to do the parts that are written out in text... Thanks! } hi there, I need to ask my users to input some numbers via textbox(or prompt) using a DELIMITER (,) between each digit. Then The program will display(list) when clicking a button. for this I will use three columns in the first column I have (2,4,6,9) to prompt. in the second column I have (3,4,7,10) to prompt. in the third columns I have (5,6,11,14) to prompt so the first lines should look like: 2,3,5 2,3,6 2,3,11 .... .... .... and the last line : 9,10,14 there should be 4x4x4=64 rows/lines How can we achieve this ? Thanks in advance hi to all... good day to u all... i have a noob question i followed this instruction Code: for (count=1; count<11; count++) { javascript code here } at the bottom of my page i did this Code: <script type="text/javascript"> for (counter=1; counter<11; counter++) { var followTrigger+counter+a = new Spry.Widget.Tooltip('following'+counter+'a', '#followMe'+counter+'a', {followMouse: true}); } </script> what im trying to do is to make multiple of this Code: <script type="text/javascript"> var followTrigger1a = new Spry.Widget.Tooltip('following1a', '#followMe1a', {followMouse: true}); var followTrigger2a = new Spry.Widget.Tooltip('following2a', '#followMe2a', {followMouse: true}); var followTrigger3a = new Spry.Widget.Tooltip('following3a', '#followMe3a', {followMouse: true}); var followTrigger4a = new Spry.Widget.Tooltip('following4a', '#followMe4a', {followMouse: true}); var followTrigger5a = new Spry.Widget.Tooltip('following5a', '#followMe5a', {followMouse: true}); var followTrigger6a = new Spry.Widget.Tooltip('following6a', '#followMe6a', {followMouse: true}); var followTrigger7a = new Spry.Widget.Tooltip('following7a', '#followMe7a', {followMouse: true}); var followTrigger8a = new Spry.Widget.Tooltip('following8a', '#followMe8a', {followMouse: true}); var followTrigger9a = new Spry.Widget.Tooltip('following9a', '#followMe9a', {followMouse: true}); var followTrigger10a = new Spry.Widget.Tooltip('following10a', '#followMe10a', {followMouse: true}); </script> i dont know why it wont work... any help pls... public static void main(String[] args){ int oddNo; oddNo = getOdd(); } public static int getOdd(){ int oddNo = 0; Scanner sc = new Scanner(System.in); while (oddNo % 2 == 0){ System.out.print("Enter an odd number : "); oddNo = sc.nextInt(); System.out.println("Wrong input ! "); } if (oddNo % 2 !=0); System.out.print("The odd number is : " + oddNo); return oddNo; } however, the output: Enter an odd number : 10 Wrong input ! Enter an odd number : 8 Wrong input ! Enter an odd number : 9 Wrong input ! (how to remove this?) The odd number is : 9 Dear all, attached is a page for my website to allow visitors to purchase photos. It is made from 2 Paypal example scripts - one for the form and another for an additional text box. It works fine apart from one detail, the text being entered does not get sent - instead, the information it forwards is "6x4 Colour Prints. Item Number id10" The "6x4 Colour prints" bit is good - the "Item number id10" is where I'd ideally like to see the custom text being entered and the guys at Paypal developer forums have said that a Javascript command is overriding the text being forwarded and to seek advice from those who know Javascript. I've tried for a day by trial and error to see if I can take this command out but it has got to the hair pulling out stage so I'm calling on those who know best to cast a wise eye over the code and see if there is an easy fix to this. Any help or suggestions as to howe to alter this will be most gratefully received. Thanks in advance, Dave. Please help me out with this. I have Vista and the easier way to compile java programs using Textpad is just not working. I have a deadline soon so I'm using command prompt. I have ensured that javac is now recognized in command prompt, and even "programname.java" is recognized in the command prompt, but for some reason, when I type javac programname.java it tells me: C:\Users\name>javac programname.java javac: file not found: programname.java Usage: javac <options> <source files> use -help for a list of possible options Thank you so much for your help! Additional information: I added javac to the "Path" system variable, following instructions I found elsewhere on this thread. When I type java -version it all looks good. I decided when it initially failed to find programname.java to add the location of the .java to the "Path" as well. I can now open the program using command prompt, but when I try javac it can't find it. I am perplexed. |