JavaScript - Obtain A Variable And Use It
Hi,
I'm looking for some guidance for the following problem. I want to submit a form but it requires a code that is generated by every session (not the php session type). What i'm looking for is for a piece of code that fetch the session code and set it as a variable that can be called in JS. I know that exists in PHP the cURL that it's able to retrieve the code and set it but i don't know how to start... Similar TutorialsHey I need help to obtain the requested javascript's query string. Example: Code: <script type="text/javascript" src="script.js?v=123"></script> How can I use that query string inside script.js for example like Code: var v = 'The code to get the query fragment'; alert(v); // alerts '123' Thank you. - DJCMBear Is there a way of doing this with java script? I have a homepage, that has to go to a certain directory, find the newer TXT file, get the first paragraph, get it formated with H1 tag, then read the rest format it with a P tag. So everytime a new TXT file is created in that directory the homepage (HTML/index.html) change. Thank in advance Miguel Sanchez Is there a way of doing this with javascript? I have a homepage, that has to go to a certain directory, find the newer TXT file, get the first paragraph, get it formated with H1 tag, then read the rest format it with a P tag. So everytime a new TXT file is created in that directory the homepage (HTML/index.html) change. Thank in advance Miguel Sanchez Hi, I have a programing problem that have been around for ages. I have search on google using several expressions and words and after hours of digging i'm still unable to do it. I would like to get a value from a HTML page hosted remotely with an inconstant value. Then define this value and name as a javascript variable and apply or show in my page. Thanks for all the help P.S. Is there any way to make a domain lookup in javascript? I mean a user enters a domain and the script converts to an ip and shows to the user. If not thanks, probably it can only be done in the server side... Hi! I have a javascript in the head of the document which has a variable named "ref2" ... ref2 is already working as I can see its value working in another function. I need to send this variable as the value of a hidden field in the form which is in the body of the document. This is my JavaScript Code: Code: function WriteContactFormStatement1 () { var ContactFormValue = ref2; document.write('<input type="hidden" name="UReferrersName" value="' + ContactFormValue + '" />'); } var WriteContactFormStatement = WriteContactFormStatement1 (); And at the end of my form, before the submit button, I have the following code: Code: <!-- START -- Javascript to print the statement for UReferrersName --> <script language="JavaScript" type="text/JavaScript"> //WriteContactFormStatement(); document.write (WriteContactFormStatement); </script> <!-- End -- Javascript to print the statement for UReferrersName --> When I execute the form, it doesn't work the way it should, plus, gives me a word "undefined" next to the "Submit" button ..... Please help !... - Xeirus. Hello I have a php page in which I declared a js variable... right at the top of the page... <script type="text/javascript"> var tester = 0; </script> Later in the page I test this variable... <script type="text/javascript"> if (tester==1){ do some stuff!! } </script> But I keep getting an error variable _tester undefined Am I missing something obvious... I am new to js... but this seems really straightforward I don't know how I should do ? Quote: <html> <head> <script type="text/javascript"> function add(a,b){ y=a+b return y } var aaa = add(one,two) //one needs to get somehow get the value of yil, in this case 10 var one = function reas(){i=10;if(i<10){yil = 15}; else{yil = 10; yil = one;}; var two = 20; document.write(y) </script> </head> </html> also why doesn't this work? Quote: <html> <head> <script type="text/javascript"> function adder(a,b){ var k=a+b; return k } var hes=adder(5,kol); kol=40; alert(hes); </script> </head> </html> you cannot have variables in callback functions? This might be a stupid question, but is there any memory usage difference between var variable1, variable2; and var variable1; var variable2;? I'm learning how to use faster code hence the question.
Hello I have a piece of javascrip that refreshes the page: ---------- Code: <script type="text/javascript"> <!-- Begin function reFresh() { location.reload(true) } /* Set the number below to the amount of delay, in milliseconds, you want between page reloads: 1 minute = 60000 milliseconds. 2 minutes = 120000 milliseconds 5 minutes = 300000 milliseconds*/ window.setInterval("reFresh()",20000); // End --> </script> -------- I am new to javascript and wanted to use an html options menu in order to be able to choose the refresh interval: Code: <SELECT NAME="refreshtime"> <OPTION VALUE="60000">1 min</option> <OPTION VALUE="120000">2 min</option> <OPTION VALUE="180000">3 min</option> <OPTION VALUE="240000">4 min</option> </SELECT> I know that I have to pass a variable to the function. I have tried several variations but none have worked. I have mostly received a "done with errors" warning. Any help would be appreciated. Thanks Zam Hello everybody I have a problem with Java Script damned I want to add the values of several variables in one variable and then use this variable, which contains the values of variables You can see the following example HTML Code PHP Code: <input type="text" name="txt1" /> <br/>age <input type="text" name="txt2" /> <br/><br/> <input type="button" name="submits" value="send"/> Javascript Code PHP Code: field = document.getElementsByName('txt1')[0]; field2 = document.getElementsByName('txt2')[0]; submit = document.getElementsByName('submits')[0]; data = 'data=' + field.value + '&data2=' + field2.value + '&submits=' + submit.value; document.getElementsByName('submits')[0].onclick = function(){ alert(data); } After executing this code I find that the variables are not displayed values As in the following picture I want to know what the cause of this problem ? If I manually write out "2/22/2012 4:00 PM" in TargetDate, I get the correct result for what I want to do (a countdown). But I want the countdown to always be the current day at 4pm. So I tried the code below thats commented, but it is not working. New to javascript, still reading the books, just hoping for some guidance on this. Code: Next Update: <script language="JavaScript"> var currentTime = new Date() var month = currentTime.getMonth() + 1 var day = currentTime.getDate() var year = currentTime.getFullYear() TargetDate = "2/22/2012 4:00 PM"; //TargetDate = "document.write(month + "/" + day + "/" + year) + 4:00PM"; BackColor = "white"; ForeColor = "red"; CountActive = true; CountStepper = -1; LeadingZero = true; DisplayFormat = "%%H%% H, %%M%% M, %%S%% S"; FinishMessage = "Forecasts posted"; </script> <script language="JavaScript" src="countdown.js"></script> Hi, I want to write some javascript code that uses arrays, I have a list of arrays named array1, array2, array3 etc. I want to perform a function on each of these arrays. I wanted to have a variable for the number after array so this is what I have: <code> var array1 = new Array ("1","2","3","4","5"); var array2 = new Array ("5","6","7","8","9"); for (var i=1; i<=2;i++){ document.writeln(("array"+i)[1]); } </code> the problem is it gives me the letters in the string array instead of the array values. How do I get javascript to treat ("array"+i) as array1? Can anyone tell me of how to take or assign a javascript variable into php.
Hello, so here's my problem. I'm trying to set a page up where I can post a list of things on one side, with a static image on the other. Each of the items on the list will be a link to the item named. The idea is that when people mouse over one of the links, the static image will change to show a picture of what the named item is. I've been tinkering around with it (I'm pretty much only doing this out of self interest, and have been using stuff like w3schools for a few weeks to self teach) and what i have so far is the following. I've a feeling I'm doing something massivly stupid or have messed up one of the commands. If anyone could take 2 minutes to have a quick look over it, i would be most grateful. Thanks in advance! Code: <script type="text/javascript"> function SwapSpecificOtherImage() { document.getElementById("SwapMe").src='cardimage'; } function SwapBackSpecificOtherImage() { document.getElementById("SwapMe").src="url of default image"; } var cardimage </script> <title>Untitled Document</title> </head> <body> <img id="SwapMe" class="thumbnail" src='cardimage' /> <a href="link to item" onmouseover="cardimage='link to image of item'">Item name</a> <a href="link to 2nd item" onmouseover="cardimage='link to image of 2nd item'">Item name</a> </body> The class thumbnail is done in the css to auto set the size of the pic. all the pics i'll be using will be portrait shaped anyways. Hi, The following loop works: Code: <html> <body> <script type="text/javascript"> var i=0; for (i=0;i<=5;i++) { document.write("The number is " + i); document.write("<br />"); } </script> </body> </html> But the following doesn't: Code: <html> <body> <script type="text/javascript"> var i=0; var x="i=0;i<=5;i++" for (x) { document.write("The number is " + i); document.write("<br />"); } </script> </body> </html> I'd just like to create a simple variable. Please bear with me as I'm a newbie in JavaScript and let me know what I'm missing. Many thanks in advance! Rain Lover I have to create a code that will prompt the user to enter a hypothetical width and length of a pool, show the area of that, then get prompt them to enter a hypothetical charge of a pool cleaning company, and get the webpage to tell how much the hypothetical bill would be. Here's the code I'm using, but it won't work for me, any suggestions would be appreciated! <script type="text/javascript"> var width= parseFloat ( window.prompt ("What is the width of the pool?")) var length= parseFloat ( window.prompt ("Length of pool")) document.write ( "The area is:"+width * length) var charge= parseFloat ( window.promt ("Charge of pool company")) var area= parseFloat ( width * length ) document.write ( "The bill would be:"area * charge) </script> Hi all, I need to get the name of a Javascript variable. For example, it would work like this: Code: var test = document.getElementById('whatever'); var name = getName(test); alert('The variable name is ' + name); Running this code would result in an alert box that says "The variable name is test". What I need to know is how to implement the "getName()" function. Thanks! -- Roger I cant seem to get the value of var drivingDistanceMiles1 outside the function it is given a value in. I need "resultsC" to return the value of the variable drivingDistanceMiles1 but can only return the value at "resultsA" Please help. PHP Code: function initialize() { geocoder = new GClientGeocoder(); gDir1 = new GDirections(); GEvent.addListener(gDir1, "load", function() { var drivingDistanceMiles1 = gDir1.getDistance().meters / 1609.344; document.getElementById('resultsA').innerHTML = drivingDistanceMiles1; }); document.getElementById('resultsC').innerHTML = drivingDistanceMiles1; } I have these lines: Quote: var ddArray=['holidayTypes','groupType','group_status']; for(var x in ddArray) eval(ddArray[x]=0); alert(holidayTypes); alert(groupTypes); alert(group_status); But it only alerts something like: Quote: object HTMLSelectElement Please help, thank you. hello How I Can make var in var like in php: PHP Code: $variable = "$var_to_get" i need to do that job in java , if possible am sorry CoZ my English not good ^_* |