JavaScript - Help With Js Transfer Question
I've done some searching and can't find an exact answer, so I'll ask it here. I want to know if it is possible (by fairly simple means) to take the results from one page and transfer it to another? Here is the dilema. I've helped with an order form page for a local company. They have to change the items and options weekly, so they chose to have the customer enter in the total for their order. They now want to add a Paypal button for those that wish to pay by credit and ahead of time. But the order form has to be submitted prior to the customer seeing the PayPal button. We decided to put it on the confirmation page IF AND ONLY IF the total amount the customer manually added could be transferred to the confirmation page. Is this possible with some script?
Similar TutorialsHi, How do I "select a 'read more' button on a page and obtain the balance of the article"? Novice...... Thank You Hi, I have a rather complicated problem for me as it involves both php and js. And I'm getting lost... Let me explain: On a page, order.html, I have a form including the following fields: - name - comment When posted, it is linked to request.php and request.validation.js, to end up on confirmation.php. On confirmation.php, I would like to reuse the information entered in the fields on order.php (name, email, comment) to display them on the page. My issue I can't find how to 'take them along' in request.php / request.validation.js to confirmation.php where I'm trying to display them with : Code: Contact: <span id="name"><?php echo($_POST['name']); ?></span> etc. For reference, here are my files request.php and request.validation.js: PHP Code: <?php // CONFIGURATION -------------------------------------------------------------- // This is the email where the contact mails will be sent to. $config['recipient'] = 'mail@mail.com'; // This is the subject line for contact emails. // The variable %name% will be replaced with the reference ordered. $config['subject'] = 'Website enquiry from %name%'; // These are the messages displayed in case of form errors. $config['errors'] = array ( 'no_name' => 'Veuillez entrer votre nom.', 'no_email' => 'Votre adresse email est requise.', 'invalid_email' => 'Votre adresse email n est pas valide.', ); // END OF CONFIGURATION ------------------------------------------------------- // Ignore non-POST requests if ( ! $_POST) exit('Nothing to see here. Please go back to the site.'); // Was this an AJAX request or not? $ajax = (isset($_SERVER['HTTP_X_REQUESTED_WITH']) AND strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'); // Set the correct HTTP headers header('Content-Type: text/'.($ajax ? 'plain' : 'html').'; charset=utf-8'); // Extract and trim contactform values $name = isset($_POST['name']) ? trim($_POST['name']) : ''; $email = isset($_POST['email']) ? trim($_POST['email']) : ''; $comment = isset($_POST['comment']) ? trim($_POST['comment']) : ''; // Take care of magic quotes if needed (you really should have them disabled) set_magic_quotes_runtime(0); if (get_magic_quotes_gpc()) { $name = stripslashes($name); $email = stripslashes($email); $comment = stripslashes($comment); } // Initialize the errors array which will also be sent back as a JSON object $errors = NULL; // Validate name if ($name == '' || strpos($name, "\r") || strpos($name, "\n")) { $errors['name'] = $config['errors']['no_name']; } // Validate email if ($email == '') { $errors['email'] = $config['errors']['no_email']; } elseif ( ! preg_match('/^[-_a-z0-9\'+*$^&%=~!?{}]++(?:\.[-_a-z0-9\'+*$^&%=~!?{}]+)*+@(?:(?![-.])[-a-z0-9.]+(?<![-.])\.[a-z]{2,6}|\d{1,3}(?:\.\d{1,3}){3})(?::\d++)?$/iD', $email)) { $errors['email'] = $config['errors']['invalid_email']; } // Validation succeeded if (empty($errors)) { // Prepare subject line $subject = str_replace('%name%', $name, $config['subject']); // Set date $todayis = date("l, F j, Y") ; // Prepare message $message = "Date: $todayis Nom: $name email: $email Commentai $comment"; // Additional mail headers $headers = 'Content-Type: text/plain; charset=utf-8'."\r\n"; $headers .= 'From: '.$email; // Send the mail if ( ! mail($config['recipient'], $subject, $message, $headers)) { $errors['server'] = 'Server problem'; } } if ($ajax) { // Output the possible errors as a JSON object echo json_encode($errors); } else { // Show a simple HTML feedback message in case of non-javascript support if (empty($errors)) { header('Location: ../steps/confirmation.php'); } else { echo '<h2>Oups!</h2>'; echo '<ul><li>'; echo implode('</li><li>', $errors); echo '</li></ul>'; echo '<br><br><a href="javascript:history.back(-1);">Retour</a>'; } } Code: /* * Request Form Validation v1.0 * By Simon Bouchard <www.simonbouchard.com> * You need at least PHP v5.2.x with JSON support for the live validation to work. */ jQuery(document).ready(function(){ jQuery('#requestform').submit(function() { // Disable the submit button jQuery('#requestform input[type=submit]') .attr('value', 'Send...') .attr('disabled', 'disabled'); // AJAX POST request jQuery.post( jQuery(this).attr('action'), { name:jQuery('#name').val(), email:jQuery('#email').val(), comment:jQuery('#comment').val(), }, function(errors) { // No errors if (errors == null) { document.location.href="confirmation.php"; } // Errors else { // Re-enable the submit button jQuery('#requestform input[type=submit]') .removeAttr('disabled') .attr('value', 'Envoyer'); // Technical server problem, the email could not be sent if (errors.server != null) { alert(errors.server); return false; } // Empty the errorbox and reset the error alerts jQuery('#requestform .errorbox').html('<ul></ul>').show(); jQuery('#requestform li').removeClass('alert'); // Loop over the errors, mark the corresponding input fields, // and add the error messages to the errorbox. for (field in errors) { if (errors[field] != null) { jQuery('#' + field).parent('li').addClass('alert'); jQuery('#requestform .errorbox ul').append('<li>' + errors[field] + '</li>'); } } } }, 'json' ); // Prevent non-AJAX form submission return false; }); }); Thanks for your help. M. Basically I have comments posted on articles and I want to allow users to report them if they find inappropriate content. I want them to be able to click on icon on the comment which will open up a pop-up. Then in the pop-up they can type why they are reporting the comment. Code: <script type="text/javascript"> function popup() { Report = window.open('/report.php','Report','width=350, height=400'); document.reportform.submit(); } </script> <form action="/report.php" name="reportform" method="post" target="Report"> <input type="hidden" name="reporter_id" value = "<?php echo $user_id; ?>" /> <input type="hidden" name="reported_id" value="<?php echo $row['uid'] ?>" /> <input type="hidden" name="comment_id" value="<?php echo $row['id'] ?>" /> <a href="#" name="reportform" class="submit" onclick="return popup();"> Report</a></form> I've been messing with this code for a while now. This code successfully brings up the pop-up, but it doesn't transfer the form data. My main coding language is PHP, and I'm in the process of learning Javascript. Can anyone help? I am trying to transfer the variables of the form (username & password )in the html page to the process.php page which are both given below. However I am not able to read those values from the process.php page. Can anyone please let me know what is going wrong here? Thanks in advance and appreciate your help. HTML Page <!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> <script language="JavaScript" type="text/javascript"> function xor_str() { var username_val = document.forms['the_form'].elements["username"].value; var password_val = document.forms['the_form'].elements["password"].value; var xor_key='1234'; var username_res=""; var password_res="" for(i=0;i<username_val.length;++i) { username_res+=String.fromCharCode(xor_key^username_val.charCodeAt(i)); } for(i=0;i<password_val.length;++i) { password_res+=String.fromCharCode(xor_key^password_val.charCodeAt(i)); } // XOR is done //shifting the username_res to the left by 1 bit //username_res = username_res << 1; //shifting the password_res to the left by 1 bit //password_res = password_res << 1; //setting the xor'ed and shifted value for submission document.forms['the_form'].elements["username"].value = username_res; document.forms['the_form'].elements["password"].value = password_res; //alert("UserName: " + username_res); //alert("Password: "+ password_res); the_form.submit(); // is this step right? } </script> </head> <body> <form name="the_form" action="process.php" method="post"> <table> <tr><td colspan="3">Username:<input type="text" name="username"></td></tr> <tr><td>Password: <input type="text" name="password"></td><td colspan="2"><input type="button" onClick="xor_str()" value="Submit"></td></tr> </table> </form> </body>s </html> Process.php page <html><body> <?php $username = $_POST['username']; $password = $_POST['password']; echo "You ordered ". $username . " " . $password . ".<br />"; echo "Thank you "; ?> </body></html> Hey friends, I'm not sure where to post this, so redirect me if there is a more appropriate location, please. I am having a very strange problem with a javascript gallery contained within a site I am working on. The problem is, that it broke (appears to be a non-working javascript) while transferring servers (from test server to client server). It makes me believe that it is a filepath problem, but I have checked over the filepaths, the javascript, the css, the html, substituted the new files back into the test server one by one, which, all work on the test server (and vice versa, the old files dont work on the new server)... and cannot seem to find the problem. I am using noobSlide gallery and have replaced the JS files incase they became corrupted in any way during the transfer. The website is located he http://www.design-evolve.com The gallery is located within Landscape-> Residential Landscape (under the Projects section). Once you reach the Residential Landscape, the Gallery is at the top of the page, and the arrows *should* scroll you through 5 images. Can anyone give me a fresh set of eyes to see if I am overlooking something? Any help would be much appreciated. Thanks, -Andrew I have this code to prompt for text input and then I want to run script.sh: Code: <script type="text/javascript"> function runscript() { var x=prompt("Enter text:"); //this is where I'm lost var xmlhttp=new XMLHttpRequest(); xmlhttp.open("GET","/cgi-bin/script.sh"); xmlhttp.send() } </script> Is it possible to substitute x above as the value for $txt in script.sh which looks like this below and how please? Code: #!/bin/bash echo "Content-type: text/html" echo "" <some xmlrpc command> "add text $txt" Hi Folks, I'm trying to figure out a script to transfer selected checkbox information to another page. I'm making a needs list for a non-profit group and the list is "huge" so I thought it would be nice to have something where the viewer could have a list of the items they checked to donate instead of printing out or transmitting the six pages for the entire list. I found a script in the archives from 10/2002 that "Adios" wrote in reply to an inquiry. It is real close to what I want but it involves transfering graphics instead of the text information from the checkbox. I've been working on it for several days but cannot get it to work. Here's Adios' script: <html> <head> <title>untitled</title> <script type="text/javascript" language="javascript"> var lefty = righty = null; function pop_twins() { lefty = open('lefty.htm','lefty','left=0,top=0,width='+screen.availWidth/2+',height='+screen.availHeight+',status=0'); righty = open('righty.htm','righty','left='+screen.availWidth/2+',top=0,width='+screen.availWidth/2+',height='+screen.availHeight+',status=0'); lefty.focus(); righty.focus(); } </script> </head> <body> <a href="javascript:void pop_twins()">pop 'em</a> </body> </html> [lefty.htm] <html> <head> <title>The Source</title> <base href="http://aabode.com/victoria/images/"> <script type="text/javascript" language="javascript"> var path = 'http://aabode.com/victoria/images/'; function addIMG() { var HTML = '', img, box_arr = document.addform.ImgAdd, which = 0; HTML += '<html><head><title>The Destination</title></head><body>'; HTML += '<h1>&#149; The Destination &#149;</h1>'; while (box = box_arr[which++]) if (box.checked) HTML += '<img vspace="5" border="1" src="' + path + box.value + '"><br>'; HTML += '</body></html>'; if (opener.righty) { opener.righty.document.write(HTML); opener.righty.document.close(); } } </script> </head> <body> <h1>&#149; The Source &#149;</h1> <form name="addform"> <input type="checkbox" name="ImgAdd" value="apple.jpg" onclick="addIMG()"> <img align="middle" vspace="5" border="1" src="apple.jpg"><br> <input type="checkbox" name="ImgAdd" value="strawberry.jpg" onclick="addIMG()"> <img align="middle" vspace="5" border="1" src="strawberry.jpg"><br> <input type="checkbox" name="ImgAdd" value="pumpkin.jpg" onclick="addIMG()"> <img align="middle" vspace="5" border="1" src="pumpkin.jpg"><br> <input type="checkbox" name="ImgAdd" value="lettuce.jpg" onclick="addIMG()"> <img align="middle" vspace="5" border="1" src="lettuce.jpg"><br> <input type="checkbox" name="ImgAdd" value="raspberries.jpg" onclick="addIMG()"> <img align="middle" vspace="5" border="1" src="raspberries.jpg"><br> <input type="checkbox" name="ImgAdd" value="tomatoes.jpg" onclick="addIMG()"> <img align="middle" vspace="5" border="1" src="tomatoes.jpg"> </form> </body> </html> [righty.htm] <html> <head> <title>The Destination</title> <body> <h1>&#149; The Destination &#149;</h1> </body> </html> I would like to also include a print function and submit. The print feature is not a big issue as the viewer can print from the browser but I thought it would make the transferred information page a bit more snazzy and they will have a record of thier selections. On the submit I don't have a URL setup yet but if you could put something like "URL HERE" in the script placement I can change it when they get up and going. Thanks in advance for your help, and thanks for taking the time to read all this. I am currently creating which will allow the user to upload their own pictures. For this I am opening a new pop up window where the user can select the file they wish and then upload it (similar to ebay's picture upload). The pop up works fine and so does the file upload however I am having trouble transferring any data from the pop up window back to the parent window. I have been investigating the opener method but cannot seem to get it to work. Below is some simple code that I've been trying to get to work... Thanks for any help! first page... Code: <form name="loadpic" id="loadpic" action="createPost.php" method="post"> <br /> <br /> Testing transfer between pages... <input type="button" value="open pop up" onclick="window.open('popup.php','pop up box','width=400,height=200')" /> <br /> <br /> <span name="myspan" id="myspan">text here</span> </form> pop up page... Code: <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Pop Up</title> <script language=javascript> function transfer(){ opener.document.loadpic.myspan.innerHTML = "working"; window.close(); } </script> </head> <body> This is the pop-up page! <input type="button" onclick="return transfer()" value="press me" /> </body> Could someone please take a look at my code? It's a simple quiz with one multiple choice question and one fill in the blank. When the user clicks on 'submit' I tried to show some kind of response with correct/incorrect images next to the question. It works with the multiple choice question, but not with the fill in the blank. How can I get the fill in the blank question to work. It always shows the answer as being wrong. Thank you. Quote: answer_list = [ ['False'], ['body','hips','knees'] // Note: No comma after final entry ]; response = []; function setAnswer(question, answer) { response[question] = answer; } function CheckAnswers() { var correct = 0; var flag, resp, answ; for (var i = 0; i < answer_list.length; i++) { flag = false; for(var j=0; j<answer_list[i].length; j++){ resp = response[i].toLowerCase(); answ = answer_list[i][j].toLowerCase(); ################################################################################################# if (response[0] == answer_list[0]) { flag = true; document.myquiz.a1c.style.backgroundImage="url('correct.gif')"; } else{ document.myquiz.a1c.style.backgroundImage = "url('incorrect.gif')"; document.myquiz.a1c.value = " ANS: False. Position the head snugly against the top bar of the frame and then bring the foot board to the infant's feet."; } if (response[1] == answer_list[1]) { flag = true; document.myquiz.a1d.style.backgroundImage="url('correct.gif')"; } else{ document.myquiz.a1d.style.backgroundImage = "url('incorrect.gif')"; } ################################################################################################### } if (flag) { correct++; } } document.writeln("You got " + correct + " of " + answer_list.length + " questions correct!"); } </SCRIPT> </HEAD> <FORM name="myquiz"> <B>1. When measuring height/length of a child who cannot securely stand, place the infant such that his or her feet are flat against the foot board.</B> <label><INPUT TYPE=radio NAME=question0 VALUE="True" onClick="setAnswer(0,this.value)">True</label> <label><INPUT TYPE=radio NAME=question0 VALUE="False" onClick="setAnswer(0,this.value)">False</label> <textarea rows="2" cols="85" name="a1c" style="background-repeat:no-repeat"></textarea> <B>2. When taking a supine length measurement, straighten the infant's <INPUT id="test" TYPE=text NAME=question1 size=10 onChange="setAnswer(1, this.value)">, <INPUT id="test" TYPE=text NAME=question1 size=10 onChange="setAnswer(1, this.value)">, and <INPUT id="test" TYPE=text NAME=question1 size=10 onChange="setAnswer(1, this.value)">.</B> <textarea rows="2" cols="85" name="a1d" style="background-repeat:no-repeat"></textarea> <INPUT TYPE="button" NAME="check" VALUE="Check Answers" onClick=CheckAnswers()> </FORM> </div> </FONT> </BODY> </HTML> hello all ive been asked to create a javascript slideshow.... and i don't really understand it that much i know a little javscript but not much........ is thier any helpful sites that i can use to teach you step by step to make a javascript slide show???? also if don't want loads of code to be used, i want the code to be clean insted of loads and loads of code what is just unessary. i will be linking the javascript file to the html file so i need to keep the code to a min LOL CHEERS I'm not sure if this is the correct forum or not, but here goes. I want to make a very simple XUL document. Just a simple basic window to be opened up, but, i want the XUL to Load and Render an HTML File. I'm not sure about what function(s) to call to achieve this, can anyone give me any ideas to go on? here's what i have so far use my JavaScript Function called LoadFromDisk(FileName), if the file is there or the load is sucessfull, it can be stored as a variable. And then i have a single Division in the XUL document called RenderWindow. From there i set the innerHTML of the RenderWindow to the data that was loaded from the disk. Is this the right way? thanks I was asked to redo a menu for this site: http://www.listlabs.com/index.php It was originally an imaged based menu, but they wanted it all changed to css/html. I used quickmenu and it used JS to produce the arrows at the top of each menu item. Now to my question... I'm trying to program the menu items to stay active when on the current page. At first, it looks correct, but if you hover back over the menu, it changes back to the inactive state. Any help would be great! Thanks. Hi all I am doing an assigment and have gotten to the end and cannot get the unordered list to work. If I try having my </script> tag below the </ul> it does not display anything If i have it above it will only display the varible names or what ever I type between the <li> </li> tag and not the varible assigment. num1,2,3,4 being the varible name. ie. </script> <ul> <li>num1</li> I have tryed <li>+num2+</li> also tryed <li>(num3)</li> also tryed <li>'num4'</li> also tryed and does not display </ul> </head> </html> The following does not display any thing <ul> <li>num1</li> I have tryed <li>+num2+</li> also tryed <li>(num3)</li> also tryed <li>'num4'</li> also tryed </ul> </script> </head> </html> I need to get the <li></li> to display not what I type in there but the assigment of the varible name I put in there.,or the output the varible calculation produces. Hope that was easy to understand lol Any advise would be awesome, cheers Shayne Darcy. Ok i have been working on this for a while now. I have to have 3 fish swim across the screen in both direction. I have tried a few things but nothing is working. Can someone please explain to me what I am doing wrong. here is my code for you guys to look at it. Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Fish tank</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <script type="text/javascript"> // <![CDATA[ var fishPos = new Array(3); fishPos[0] = "fish1.gif"; fishPos[1] = "fish2.gif"; fishPos[2] = "fish3.gif"; var fillPosition = 10; for(var i = 0; i < 50; ++i) { horizontal[i] = fillPosition; fillPosition += 10; } function fishSwim(fishNumber) { document.getElementById("fishPos").style.left = horizontal + "px"; ++fishPos[fishNumber]; if (fishPos[fishNumber] == 49) fishPos[fishNumber] = 0; } function startSwimming() { setInterval(fish1Swim, 100); } // ]]> </script> </head> <body onload="startSwimming();"> <p><span id="fish1" style= "position:absolute; left:10px; top:10px"><img src="fish1.gif" alt="Image of a fish" /></span></p> <p><span id="fish2" style= "position:absolute; left:10px; top:120px"><img src="fish3.gif" alt="Image of a fish" /></span></p> <p><span id="fish3" style= "position:absolute; left:10px; top:250px"><img src="fish2.gif" alt="Image of a fish" /></span></p> </body> </html> I am really not understanding and in my book it only give me a page to read about the animation. I am still new to it. Thanks for looking Hello, i haven't understood how to find the id from buttons, links, button images to auto click yet for example, i want to CLICK HERE how can i do that? how i find the id (I Own firefox with firebug and know basic html) it will be something like javascript:document.GetElementById('id').click(); right? but just want to know how to find or create ids on sites for auto click thanks You are given a mathematical expression containing integers and the basic operations: *,+,-, /. Find the number of unique results that can be obtained by parenthesizing the expression differently. i.e., by changing the order of evaluation of the operations. Note that all operations are integer operations. For example, if the input is 2 ∗ 3 + 6/2, your output should be 4. Plzz help me with this qs......... Hi all, I am trying to do a simple "animation" of the background color of a button. I want it to do 10 different colors in the course of 1 second. I have a loop like this (pseudo code): Code: var e = "the button element"; var c = 10; while (c--) { setTimeout(function(){ e.style.backgroundColor=(random color); }, (c * 100)); } I expect that 10 instances of "setTimeout" would be created, each one timing out 0.1 seconds later than the previous one, giving me an "animation" of 10 different colors over the course of 1 second. Strangely, it doesn't work. All it does is WAIT one second, then set the background to the LAST color. What am I doing wrong? I can't see it. Thanks! -- Roger Edit: I also tried to do the loop forward instead... no difference. I would like to type something into my textbox and then press ENTER, it will execute a function. I tried onFocus, onChange and onBlur but it doesn't do what I want it to. Here's an example I use for onChange. Code: Application: <input type="text" onchange="execProg(0);"> Any comments or suggestions is greatly So, I've built this navigation bar so far and I'm curious if it's even possible to achieve what I'm thinking. Currently, when you hover over each of the links they drop down (padding is increased). Now, what I'm curious in doing is if you hover over say "test1", test2-4 also drop with it but in the padding that has been created from the drop down, "test1" information shows up. Allowing the user to click or read whatever information is in there. Also, if the user would like to, they can move their mouse to test2 and everything would animate (opacity, this I can do I think) to whatever is in the test2 field, test3 doing the same and so on. I haven't had much success with this, I've created a completely separate panel before, but that didn't exactly work or I wasn't doing it correctly. Here is what I've been working on, ANY help would be appreciated! Thanks! Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> $(function() { $("#nav li > a").hover(function() { $(this).stop().animate({paddingTop: "100px"}, 100); }, function() { $(this).stop().animate({paddingTop: "10px"}, 200); }); }); </script> <style type="text/css"> #nav { position: absolute; top: 0; left: 60px; padding: 0; margin: 0; list-style: none; } #nav li { display: inline; } #nav li a { float: left; display: block; color: #555; text-decoration: none; padding: 10px 30px; background-color: #d1d1d1; border-top: none; } </style> </head> <body> <div id="wrap"> <ul id="nav"> <li><a href="">test1</a></li> <li><a href="">test2</a></li> <li><a href="">test3</a></li> <li><a href="">test4</a></li> </ul> </div> </body> </html> |