JavaScript - How To Pass Variables To A Popup Page?
Hi,
i need to pass variables to a popup page. I have already made the page i want to be popped up, it is called popup.html and is in the same file location. Here is how i am making the page popup: Code: <head> <script type="text/javascript"> function prizes(){ var prize1 = ..... var prize2 = ..... .ect .ect myRef=window.open('popup.html','mywin','left=20,top=20,width=500,height=500,toolbar=0,resizeable=1'); myRef.focus() } </script> </head> so now i need the variables prize1, prize2....ect. to be used in the popup.html page. i now its nearly xmas but i need this for tomorrow so please help ASAP, PLEASE!! Thanks in advance! Thorbob Similar TutorialsI have a form with allot of form items on it that posts to itself. I am trying to pass those form values to another page with out using the action attribute in the form. Is there a way to do this? I have tried jquery and javascript but coming up blank. Just trying to pass all the values at one time to another page. Seems a little difficult to me since im a intermediate javascript programmer. Any ideas are welcome and thank you in advance if someone knows how to get this going. Here is what i am trying to do script wise. theform is the ID of the form. I have a switch statement that is based on the button pressed would get into that statement. So if one of the three buttons on the page is "excel report" it should get into that statement and pass the values of the form to another page. I have tried this: Code: <cfswitch expression="#LCase(Trim(FORM.submit))#"> <cfcase value="Excel Report"> <cfoutput> <script> function formSubmit() { var form = document.forms.theForm; // change the url form.action ="index.cfm?keyword=Report PDF New"; form.submit(); } </cfoutput> </script> </cfcase> </cfswitch> AND This: Code: <cfswitch expression="#LCase(Trim(FORM.submit))#"> <cfcase value="PDF Report"> <script> $('##submit').click(function(){ open('',"results"); with(document.print) { method = "POST"; action = "index.cfm?keyword=Report PDF New"; target = "results"; submit(); } }); </script> </cfcase> </cfswitch> I have a popup window which display a list of values in a tabular form. I have no problem to do the popup or display the table. The table has two columns; one is the "code" and the other is the "description". When a row is highlighted and the "SELECT" button in the popup window is clicked, I am supposed to pass the "code" of the highlighted row back to an input textfield in the parent window. And I am struggling with it. Would anybody kindly help? Total newbie, I (almost) know just basic HTML. I have my own website and I'm trying to find out how to make a popup window work from clicking on a part link in a parent window table so that my clients can make an inquiry. I have about 300 parts on 10 pages total and would like it to be something I can just enter the new varibles on the parent page and the code takes care of the rest. I would like the popup to have the part info as a variable from the table as a variable in the inquiry page header and also part description as a variable the hidden subject line. I have included the code I already have and I'm looking for the script to bring it all together. Example for header may read "Part 1" for example and the hidden subject variable to read "0001 Part 1 $20" for example. I hope this is possible and I hope I made sense. I really need help me with this. Parent page Code: <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>Parts Page</title> <link rel="stylesheet" type="text/css" href="../styles.css" /> <style type="text/css">body{font-family: Verdana, sans-serif;font-size: 14px;font-style: normal;line-height: normal;font-weight: normal;color: #000000;}</style> </head> <body> <div align="center"><table width="90%" style="border-collapse:collapse;" border="1" cellpadding="2"> <tr><td width="15%"><h2 align="center">Item #</h2><p align="center">Click to inquire</p></td> <td width="60%"><h2 align="center">Description - Used OEM Parts*</h2><p align="center">*Unless described differently</p></td> <td width="15%" valign="top"><h2 align="center">Coverage</h2><p align="center">*Sorted by Year</p></td> <td width="10%" valign="top"><h2 align="center">Price</h2></td></tr> <tr><td align="center"><a href="mailto:myemail@myweb.com?subject=0001 - My Part 1 - $20"><font size="2">0001</font></a></td><td align="left"><font size="2">My part 1</font></td><td align="center"><font size="2">1960-61</font></td><td align="center"><font size="2">$20</font></td></tr> <tr><td align="center"><a href="mailto:myemail@myweb.com?subject=0002 - My Part 2 - $25"><font size="2">0002</font></a></td><td align="left"><font size="2">My part 2</font></td><td align="center"><font size="2">1960-61</font></td><td align="center"><font size="2">$25</font></td></tr> </table></div> </body> Popup window Code: <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>Parts Inquiry</title> <link rel="stylesheet" type="text/css" href="../styles.css" /> <style type="text/css">body{font-family: Verdana, sans-serif;font-size: 14px;font-style: normal;line-height: normal;font-weight: normal;color: #000000;}</style> </head> <body> <form action="http://www.myweb.com/cgi/FormMail.pl" method="post"> <input type="hidden" name="recipient" value="myemail@myweb.com" /> <input type="hidden" name="subject" value="variable 2" /> <input type="hidden" name="redirect" value="http://myemail@myweb.com/used_parts/thank_you6.html" /> <input type="hidden" name="required" value="realname, email" /> <input type="hidden" name="env_report" value="REMOTE_HOST, HTTP_USER_AGENT, REMOTE_USER, REMOTE_ADDR " /> <div align="center"><table width="90%" border="0"> <tr><td align="center"><h1>variable 1</h1> <p align="center"><font size="2" color="#FF0000">"*" Indicates required field.</font></p> <p><font>Fill out the form below to find out more about this this part.</font></p> </td></tr></table></div> <div align="center"><table width="50%" border="2" bgcolor="#99CCFF"> <tr><td align="right" width="50%"><font color="#FF0000">*</font>Your Name : </td> <td align="left" width="50%"><input type="text" size="35" maxlength="256" name="realname" /></td></tr> <tr><td align="right" width="50%"><font color="#FF0000">*</font>Email Address : </td> <td align="left" width="50%"><input type="text" size="35" maxlength="256" name="email" /></td></tr> <tr><td align="right" width="50%">Phone Number : </td> <td align="left" width="50%"><input type="text" size="14" maxlength="256" name="Phone" /></td></tr> <tr><th colspan="2">Please type your question(s) in the space below: <textarea name="Question(s)" rows="5" cols="70"></textarea></th></tr></table></div><br /> <div align="center"><table width="90%" border="0"> <tr><td align="center"> <input type="submit" value="Submit Form" /> <input type="reset" value="Clear Form" /> </td></tr></table></div></form> </body> I also have some parameters for the desired popup window size and position. Code: width=625,height=450,left=275,top=100,resizable=no,status=no,toolbar=no,menubar=no,location=no'); Any other suggestions for the popup window parameters would be welcome! Thanks, John Hey there, I'm using the service from Maxmind to get user's postal code, what I wanna do is pass the value to the next page using GET function.. I am quite new to PHP, however I think I should name the variable first and call it on the next page right? But it doesn't seem to work. Any help is much appreciated! Thanks! Hello. I am very new at using javascript and jquery. Right now Im working on a website, and it has a hierarchical menu in the right and im also doing some content loading in a div, all that with javascript. My problem is that when they click on a link, I need to pass a variable "id" through the link. I dont want to pass it in the url, but I want to pass it in another way, for every link the id is going to be different. How can I pass a variable to another page and how can I retrieve it in that page so I can use it for the content loading? Thanks! Hello Guys, I need some help here.. I have a page that has a grid on it and I have a hidden div(below the grid). When the link is clicked inside the grid it opens the hidden div using the following code for the link in the grid. Here is my code with the PHP id that I need to pass PHP Code: foreach($ct->data as $key => $value){ $ct->data[$key][3]='<a href=#" onclick="part2('.$ct->data[$key][0].');" href="javascript:void();">'.$ct->data[$key][3].'</a>'; Here is the code in my head Code: <script type="text/javascript"> function part2(id) { var part2 = document.getElementById('part2'); if ( part2.className == 'hidden' ) { part2.className = 'visible'; document.getElementById('message').InnerHTML = 'This is the ID: '+id } else { part2.className = 'hidden'; } } </script> Added this to my hidden div to show the id Code: <span id=message></span> Any help would be appreciated.. Thanks, Dan ok i have auto complete that i want to be able to select a column of the database before searching on it i just want to pass the oneone variable over to the php page. so i have this javascript Code: <script type="text/javascript"> $().ready(function() { function log(event, data, formatted) { $("<li>").html( !data ? "No match!" : "Selected: " + formatted).appendTo("#result"); } $("#search").autocomplete("test.php", { width: 260, selectFirst: false }); $("#search").result(function(event, data, formatted) { if (data) $(this).parent().next().find("input").val(data[1]); }); $(":text, textarea").result(log).next().click(function() { $(this).prev().search(); // shows resluts }); }); </script> the html Code: <p class="field" > <select id="oneone" name="oneone" style="width:100px;margin:5px 0 5px 0;" value=""> <option value="s_last">Last Name</option> <option value="s_first">First Name</option> <label>Search</label> <input type="text" id="search" /> </p> <p> <label>Hidden input</label> <input type="text" id="inputit" /> Hi coders, I have a login form which has the following code: Code: <p> Username:<span><input type="text" id="uid" name="uid" size="14"/> </span> Pass:<span><input type="password" id="pwd" name="pwd" size="14"/></span> <a onclick="return loginload()" href="#" class="btn">Enter</a> Here is the loginload script directs me to the following page upon Enter: Code: function loginload() { window.location="step1.asp"; } Now that step1.asp gets the user & pass variables and pass them to step2.asp page that way: Code: <html> <!-- #include file="include/common.asp" --> <!-- #include file="include/security.asp" --> <head> <meta http-equiv="Content-Language" content="tr"> <meta name="GENERATOR" content="Microsoft FrontPage 12.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1254"> <META HTTP-EQUIV="Pragma" CONTENT="no-cache"> <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache"> <title>Login</title> </head> <body background="webimages/BGS/Gray.jpg" bgcolor="#D6D6DE" topmargin="2" leftmargin="35" oncontextmenu='return false' ondragstart='return false' onselectstart='return false'> <form name="frm1" method="post" action="step2.asp"> <input type="hidden" name="_uid" id="_uid"> <input type="hidden" name="_pwd" id="_pwd"> </form> <SCRIPT> document.forms[0]._uid.value = document.getElementById("uid").value; document.forms[0]._pwd.value = document.getElementById("pwd").value; document.forms[0].submit(); </script> </body> </html> After clicking on Enter on the login page, I receive the error for the step1.asp page: Line:20 Char:1 Object Required Code:0 Url=step1.asp Line 20 is the beginning of the script. Could not figure it out. Any opinions/advise are wellcome. I'm working on a site with someone else and they would like the username to be entered in a form on a page, then passed to a second page that says 'Welcome [username]'. I am aware of how to do this using var prompts on the SAME page, but what about different pages. I'd also like to know how secure this is? The name is being used in a page (i.e. login.php) and passed to another page (i.e. welcome.html). The person has requested Javascript. How could this be done? If there is a better way to do so, what is it?
Hi all, I have an .xsl file that reads an xml file and populates an html file and that is working well. I want to have many xml files (one per project) and one .xsl and html file. The goal would be to get the user to browse for the particular xml file they want to use and have the html file reference the path and file name. There will be a main page where the user will browse for the xml file in question. When they hit submit, the information (document path) is passed to the html file and the html file opens with information from the xml page they selected .In my html file I have the following: Code: xml.load(''12345.xml'') Basically I would like to somehow browse to the xml file in question and pass that variable (file path and name) to the html file and replace "1234.xml" with the path and name selected by the browse section. Does this make sense? Thanks. Reply With Quote 01-22-2015, 11:04 PM #2 Old Pedant View Profile View Forum Posts Supreme Master coder! Join Date Feb 2009 Posts 28,310 Thanks 82 Thanked 4,754 Times in 4,716 Posts The easiest way to do this would be via server-side code. For example, just have a PHP page the includes the desired ".xml" file into a page that is already setup with the XSLT. I vaguely recall reading that there is a way to "apply" XSLT to a dynamic set of XML, but the function named apply() in XSLT doesn't do anything like this. Still, the easiest way to control this would be via the server side code. Heck, that would even allow you to string together "pieces" of XML from various files to create the final document. PLEASE IGNORE - I'D DONE A BOO BOO! </facepalm> Hi guys, not sure i have a decent explanation in the title. so, let me explain. i have a script that collapses rows in tables but i create the array in php. the button needs to be above the content else i could just create it using php if i try this function in a .js file it all works: Code: function toggleAll() { //collapse all layers in var togglelist = "['380','379','378','377','376','374','373','369','367']"; for (var i=0; i<togglelist.length; i++) { collapseTableRows(togglelist[i]); } } the problem is that i need to create togglelist when im doing the php. if i just do a simple: Code: <script> var togglelist = "['380','379','378','377','376','374','373','369','367']"; </script> at the bottom of the page i cant seem to pass togglelist to the function in the .js file im a bit rusty at JS so i think im doing something wrong. or is it just that i cant pass a variable array to a function if the variable is below the function on the page... i hope that makes sense. Hi I have seen this popup in a registration form. I think it's using jquery but I don't know how can I make some thing like this . I want to put a registration form in it ( ajax registration ) when the popup appear , around it will became dark how can I do so ? thanks Hi I want to create a popup that is completely contained within the page (so i guess its not really a popup). I'm looking for something where if a button is clicked, a small box will come up in the current window and become the active window, while the original window is visible but not active. It's hard to explain, but its a popup that is contained in the same window. And when the user presses okay or cancel on the "popup" window. They return to where they were in the original window. Is this possible? How would I do it? Thanks I have a web site application written in VB.net and asp. The main page uses JavaScript to load a popup page that performs multiple tasks. The main page accepts a variety of incoming messages, only SOME of which need to be passed to this popup page for processing. I found an ugly way to pass the message to the popup by placing it in a Session variable. Now I need to cause it to be handled. I see two possibilities, and I do not have a clue how to implement either. Either one would be great: 1. In the main page, trigger a subroutine in the popup, using JavaScript. OR 2. In the popup, establish a trigger any time that Session variable changes. I have a page that loads a fancybox popup and it works perfectly with the cookie for setting ho many days to show. the problem i have is that i need it to show 1 every 24 hours over a 3 day period. once the 3rd day is over and the user sees the window for the 3rd day i need a cookie set to never show the window again. here is my code as it sits now. I have worked with this for a couple of days on and off and it is above my head for sure. any help is appreciated. $(function() { if ($.cookie('moment_comm')) { // it hasn't been 1 day yet } else { $("#autostart").fancybox({'overlayShow':true,frameWidth: 840,frameHeight:360}).trigger('click'); } } ); $('#autostart').live('click', function(e) { e.preventDefault(); $.cookie("moment_comm", "true", { path: '/', expires: 1 }); $.fancybox.close() }); First, I will state that I am totally inexperienced in JavaScript. I have a web site application written in VB.net and asp. The main page uses JavaScript to load a popup page that performs multiple tasks. The main page accepts a variety of incoming messages, only SOME of which need to be passed to this popup page for processing. I found an ugly way to pass the message to the popup by placing it in a Session variable. Now I need to cause it to be handled. I see two possibilities, and I do not have a clue how to implement either. Either one would be great: 1. In the main page, trigger a subroutine in the popup, using JavaScript. OR 2. In the popup, establish a trigger any time that Session variable changes. Thanks in advance for any help on this. Hello, I had a php page, which contains links when I click on a link it will issue a new page, I want to make the main page to be refreshed once the new page being closed. Any suggestions? thanks Hello: I have the following div popup window: PHP Code: <div id='PopUp' style='display: none; position: absolute; height: auto; left: 13px; top: 10px; border: solid black 1px; padding: 10px; background-color: rgb(255,255,225); opacity:.95; text-align: justify; font-size: 12px; width: 70%; z-index:1200;'> <iframe id="mate\" frameborder=0 scrolling=yes width=100% src='client_edit/edit_client_data.php?customerid=$customerid' height=\"790\" align=\"left\"></iframe><br /> <div valign=\"top\" style='text-align: right; display: inline; position: absolute; left: 10px; top: 10px;'><a onmouseover='this.style.cursor=\"pointer\" ' style='font-size: 12px;' onfocus='this.blur();' onclick=\"document.getElementById('PopUp').style.display = 'none' \" ><span valign='left' style=\"text-decoration: underline;\" ><img border='0' src='images/the-delete.png' width='22' height='20' title='Close Window'></span></a> </div></div> the popup is opened from its parent page with the following onclick event: PHP Code: <a href="javascript:void(0)\" onmouseover=\"document.edit_info.src='images/edit-user-info2.png'\" onmouseout=\"document.edit_info.src='images/edit-user-info.png'\" onclick=\"document.getElementById('PopUp').style.display = 'block' \"><IMG SRC=\"images/edit-user-info.png\" NAME=\"edit_info\" width='40' height='40' title='Edit Customer Contacts' ALT=\"...\"></a> Now when the popup is closed, I would like the parent page to automatically refresh. I would appreciate some help on this. To close the popup, the following is invoked: PHP Code: <div valign="top\" style='text-align: right; display: inline; position: absolute; left: 10px; top: 10px;'><a onmouseover='this.style.cursor=\"pointer\" ' style='font-size: 12px;' onfocus='this.blur();' onclick=\"document.getElementById('PopUp').style.display = 'none' \" ><span valign='left' style=\"text-decoration: underline;\" ><img border='0' src='images/the-delete.png' width='22' height='20' title='Close Window'></span></a> </div> Hi I wanted to control parent page form popup. For example, I have a page: http://www.cmela.com/zz.php When i open a popup by clicking "Click Here to open popup page" and then on popup window, i wanted it to transfer parent page from making a click on a pop up window. Example is at: http://www.cmela.com/zz.php open pop up window, and then by clicking on a link on a pop up window i wanted my parent page to go to www.msn.com any help? Thanks Hi, I'm looking for help, please. I am trying to setup a donation form for a friend, where someone can click radio buttons for set donation amounts, or click the "other" radio buttons and enter a different amount. The donation amount is then passed over to a secure credit card entry page, hosted by a 3rd party merchant. I can set up all the pre-defined radio buttons to correctly pass on the donation amount to the credit card page, but I cannot figure out how to work the "other" radio button amount. Any help would be very much appreciated! Thanks! |