JavaScript - Form Submit Can't Sen Post Data To Greybox Window
Hi friends,
i'm using greybox on my website, and using survey. i want when click submit button then post form data to opened greybox window.. but can't.... my form actions <form action="anket.php?islem=ok" method="post" onSubmit="javascript:return GB_showCenter('Anket',this.action, 280, 350)" > greybox window open, but can't show post data.. can anyone help me ? sorry for may bad english Similar TutorialsHi guys, hoping you can help me out again, with this new problem. I've got a form which is acting as a calculator. Once the calculation is complete I want it so when the user presses a 'print' button it takes certain parts of the form data and displays them in a new window which would be designed for printing. how can i go about this using only javascript? thanks This one is tricky. I can do this in php, however, I would like to keep everything on the same page. In a nutshell I'd like my users to export some data but after they click the export button I need them to input a key which will then be placed into a variable and the posted. Here's a simplified version of how script works without the key: Code: <?PHP if(isset($_POST['Export'])){ $file = $_POST['Export']; $hostname = $_SERVER['SERVER_NAME']; $hostname = str_replace('www.', '', $hostname); $file_location = "http://".$hostname."/filelocation/".$file; $list = file_get_contents("$file_location"); # filename for download $filename = "$file.txt"; header("Content-Disposition: attachment; filename=\"$file\""); header("Content-Type: text/plain"); echo $list; } ?> <form action="" method="post"> <input type=hidden value="$file" name="Export"> <input type=submit value="Export"></form> I know this is a javascript category and I have php. However, what I want is javascript. My users cannot access the page (traditionally) because a key needs to first be submitted. This is what I need help with > Find a way to use javascript when the 'Export' button is pressed to open a pop-up window for the user to submit their key. > Place there key into a variable. From there I can use PHP to post the variable, extract the data and allow the user to export. Something like this: Code: if(isset($_POST['Export'])){ //The user pressed the export button - use javascript to envoke pop-up //<!--javascript pop-up code--> //The user submitted their key - place it in a variable //<!--javascript code to post key into variable--> $key = $_GET['key']; $file = $_POST['Export']; $hostname = $_SERVER['SERVER_NAME']; $hostname = str_replace('www.', '', $hostname); $file_location = "http://".$hostname."/filelocation/".$file."php?key=".$key; $list = file_get_contents("$file_location"); # filename for download $filename = "$file.txt"; header("Content-Disposition: attachment; filename=\"$file\""); header("Content-Type: text/plain"); echo $list; } ?> <form action="" method="post"> <input type=hidden value="$file" name="Export"> <input type=submit value="Export"></form> If I can get the user to place a key in a simple input box (through a javascript pop-up after they've clicked the button) then I can post the variable and retrieve the data. Any ideas? Hi there i have a simple form in a popup window that was called like this: Code: document.onkeyup = KeyCheck; function KeyCheck(e) { var KeyID = (window.event) ? event.keyCode : e.keyCode; switch(KeyID) { case 40: window.open("?page_id=9","MS_PopUp","width=800,left=100,top=100,height=630,toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=0,copyhistory=1"); break; } } This works well enough. The form has a four fields: Code: <form name="contact_form" id="form1" method="post" action="?page_id=41"> <fieldset> <label class="label" for="name">Your Name: </label> <input tabindex="1" type="text" id="name" name="name" class="input" onload="focus()" /><span id="error_name"> </span><br /> <label class="label" for="email">Your Email: </label> <input tabindex="2" type="text" id="email" name="email" class="input" /><span id="error_email"> </span><br /> <label class="label" for="website">Your Website: </label> <input tabindex="3" type="text" id="website" name="website" class="input" /><span id="error_website"> </span><br /> <label class="label" for="problem">Your Problem: </label> <textarea tabindex="4" class="textarea" name="problem" id="problem" rows="5" cols="10"></textarea><span id="error_problem"> </span><br /> </fieldset> <div class="buttons"> <input tabindex="6" type="button" value="Reset" onclick="resetForm()" /> <input tabindex="5" type="button" value="Send" onclick="popupmail()" /> </div> </form> and the function 'popupmail()' ends with Code: document.contact_form.submit() ; which i used on numerous forms before. after submit, the action URL (?page_id=41) is displayed in the popup window location bar but the page is not! 'page not found'. if i copy & paste the URL and refresh, the page is found. this may not be a JS problem but maybe a popup window limitation. but what do i know? also, this is a wordpress site but i cant see how this is related to wordpress. any idea? Trying to create an eBay listing template with a form on it. The form will allow the buyer to enter in their ebay ID, item number, and 3 choices. Form is complete, using this javascript for validation: Code: <SCRIPT language=javascript> function validate(){ var ebayid= document.getElementById('ebayid').value; var itemnumber= document.getElementById('itemnumber').value; var choice1= document.getElementById('choice1').value; var choice2= document.getElementById('choice2').value; var choice3= document.getElementById('choice3').value; if (!ebayid){ alert('Ebayid is required!'); document.getElementById('ebayid').focus(); return false; } if (!itemnumber){ alert('Item Number is required!'); document.getElementById('itemnumber').focus(); return false; } if (!choice1){ alert('Choice 1 is required!'); document.getElementById('choice1').focus(); return false; } if (!choice2){ alert('Choice 2 is required!'); return false; } if (!choice3){ alert('Choice 3 is required!'); return false; } return true; } </SCRIPT> I like this because it gives a pop up alert box (with definition) if a field is left empty. Upon success though the user is redirected off the page to a success page. I was told that this has to happen because the .php for the form to work is hosted on my site and the user needs to be redirected to my site in order for the form to work. Since this is the case, I was told I could use javascript to open up a separate window for this to happen, thus allowing the buyer to stay on the eBay listing (and to stay compliant with eBay's html/javascript policy). I have pieced together code from numerous forums to actually do this but there is one flaw. Code: <form action="http://www.mysite.com/test.php" method="post" name="testform" id="testform" onsubmit="window.open('', 'success', 'width=450,height=300,status=yes,resizable=yes,scrollbars=yes'); javascript:return validate();" rel="nofollow" target="success"/> This code not only opens a new window but it opens the new window on any click to the submit button, even if the validation fails. How do I write this so that the new window is only opened when the validation completes all true and not when the validation returns an error/alert box? Additionally... how do I add to the javascript so that the field "ebayid" requires 6 characters and the "itemnumber" requires 12 numbers? I would also like for the form itself to erase after a successful submission to prevent the user from hitting the submit button 100's of times spamming me with email (if it's possible) Thanks Kemble Hey Guys, A litttle new to web coding so bare with me(hope this is posted in the right section). Im workin on a backend panel where i populate a simple table with a few text boxes in there so they can update some values. I also have at the end of every row in the table an Edit, Delete & Save button. When i hit the save button i would like to update that entry in the database. My Problem is that i need a value from the table before hitting a submit button, and the element names are dynamically created meaning ill likely need a variable sent from php to javascript and once i have the value in javascript ill need to send it back over to the php to manipulate and send to the server. From wat i can gather using 'document.form.element.value' is the best way to go, hence why i posted this in javascript when most of my code is php. PLEASE HELP Hello all, I need my form to submit to two sources, zoho crm and broker office. One is used to create a contact list and the other is an insurance quote engine. Problem one. How can I use javascript to force my form to submit data to both sites? The bigger problem is they use different names for the same field. In other words one wants to recieve a vaule as first_name and the other wants it as firstName. Thanks in advance. I want to use Javascript to submit a form - without filling the form in physically Is this possible? Let's say a web page has a form that submit First Name and Last Name to the next page Instead of filling in the form and hitting submit, can I submit the data in variables and call the next page somehow using Javascript? Thanks OM Hi, I have a problem with sending data from a form to a php script with AJAX. To test if it works, I try to send data from the form, print it in the php with "echo", and then put it back in the initial html file. My Javascript code is: Code: function registerPrivateUser() { xmlhttp=GetXmlHttpObject(); if (xmlhttp==null) { alert ("Your browser does not support AJAX!"); return; } var postData="firstName="+ document.getElementById("txtFirstName").value; var url="classes/users/checkRegistration.php"; xmlhttp.onreadystatechange=stateChanged; xmlhttp.open("POST",url,true); //xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); xmlhttp.send(postData); } The function stateChanged, basically says: Code: if (xmlhttp.readyState==4) { var strResponse; strResponse=xmlhttp.responseText; alert('Response:' + xmlhttp.responseText); } checkRegistration.php looks like this: PHP Code: <? session_start(); $firstName=$_POST['firstName']; echo($firstName); ?> The problem is that the response is empty, but I don't know why. I have checked the input data and the postData variable says "firstName="+input (e.g. "firstName=Robert"), so that's not the error. I have read several forum posts here, but still haven't figured out what I'm doing wrong. If anyone could please tell me, I would appreciate it alot. 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> [help] i have the big problem,,, how script to make data to new window (after that, output can print) n data from previous window with datatables (datatables.net) and with default header n footer in new window??? case: [datatable] i search with datatable and have 3 record... and show in new window with default header n footer company , and in new window have function to print the record with header and footer. I hope, anybody can help me..Please thank you Hi everyone, I have a problem with something I am trying to do. I have a submit button and once I press it I want it to add a post value to my website. For example my website is www.something.net/test.php and once I press it I want it to refresh the site and becomes something like www.something.net/test.php&ca=test In other words I want it to use POST and then using GET I can get the value of the POST. I have posted this under javascript because I believe I have a problem with the javascript I use. Here is the javascript and the button I use Javascript Code: function reload(val) { //var val=form.accept.id; self.location='test.php?ca=' + val ; } Button Code: <form name='form1' method='post' action='' STYLE='margin: 0px; padding: 0px;'> <input type='submit' name='accept' id='trial' value='Approve' onclick=\"reload(test)\" /> </form></div></td>"; Can you please help me with that? I am trying to get a Javascript "script" to do a function for me. I am trying to write a a script that will run while the webpage is open, that is selected a randomized 9 digit number Less than 350000000 that will be put into a textbox and submitted. I want a adjustable time when it submits. Could this be made into an <iframe>? Also, this has to do it to a different website, not the one locally being opened. Thank you for your help. When the form below is submitted, I want the result page to open in the same window. I tried adding 'rel="nofollow" target=_self', but that didn't do the trick (Another option is to open the new page in a new window with pre-defined dimensions) Can someone help me out? Code: <form action="banner.php" name="fastbanner" method="post" > <TR> <TD align="center"> <table cellspacing="0" cellpadding="0" width="67%"> <tr> <td width="75%"> <TABLE summary="table" cellspacing="0" cellpadding="0" border="0" width="100%" align="center"> <TR> <TD class="border"> <TABLE summary="table" border="0" cellspacing="1" cellpadding="3" width="100%"> <TR> <TD colspan="5" class="header"> Select Your Banner. </TD> </TR> <TR> <TD class="main" colspan="5" align="center"> <select name="select_banner" onChange="showimage()"> <?php $open = opendir("banner"); while ($files = readdir($open)) { $filename = $files; if ($filename == "."){ print "\n"; } elseif ($filename == ".."){ print "\n"; } else { print "<option value=\"$filename\">$filename</option>\n"; } } ?> </select><br> <table cellspacing="0" cellpadding="0" width="484" summary="Banner Table"> <tr> <td rowspan="2"><img src="Yscala1.gif" width="16" height="79" border="0" alt=" " /></td> <td><img src="Xscala1.gif" width="468" height="15" border="0" alt=" " /></td> </tr> <tr> <td valign="top"><img ismap onclick="alert('Coordinates:\n\nX POS: '+self.event.offsetX+'\nY POS: '+self.event.offsetY);" name="banner" src="banner/ban01.png" width="468" height="60" /></td> </tr> </table> </TD> </TR> </TABLE> </TD> </TR> </TABLE><br> <TABLE summary="table" cellspacing="0" cellpadding="0" border="0" width="100%" align="center"> <TR> <TD class="border"> <TABLE summary="table" border="0" cellspacing="1" cellpadding="3" width="100%"> <TR> <TD colspan="1" class="header"> Pick your title text. </TD> </TR> <TR> <TD class="main" colspan="4"> <table cellspacing="0" cellpadding="0" width="100%"> <tr> <td width="100"><input name="titletext" value="YourSite" size="43" maxsize="80"></td><td><INPUT type="text" size="7" name="titlecolor" maxlength="7" value="#009900"></td> </tr> <tr> <td> <map name="colmap"> <area shape="rect" coords="1,1,7,10" href="javascript:showColor('#00FF00')"> <area shape="rect" coords="9,1,15,10" href="javascript:showColor('#00FF33')"> <area shape="rect" coords="17,1,23,10" href="javascript:showColor('#00FF66')"> [...] </map> <img usemap="#colmap" src="colortable.gif" border=0 width=289 height=67></td> <td><input name="titlex" type="text" value="54" size="3" maxsize="3">X Coordinates<br> <input name="titley" type="text" value="10" size="3" maxsize="2">Y Coordinates</td> </tr> </table> </TD> </TR> </TABLE> </TD> </TR> </TABLE><br> <TABLE summary="table" cellspacing="0" cellpadding="0" border="0" width="100%" align="center"> <TR> <TD class="border"> <TABLE summary="table" border="0" cellspacing="1" cellpadding="3" width="100%"> <TR> <TD colspan="1" class="header"> Pick your tag text. </TD> </TR> <TR> <TD class="main" colspan="4"> <table cellspacing="0" cellpadding="0" width="100%"> <tr> <td width="100"><input name="tagtext" value="This is my tagline." size="43" maxsize="80"></td><td><INPUT type="text" size="7" name="tagcolor" maxlength="7" value="#009900"></td> </tr> <tr> <td> <map name="colmap2"> <area shape="rect" coords="1,1,7,10" href="javascript:showColor2('#00FF00')"> <area shape="rect" coords="9,1,15,10" href="javascript:showColor2('#00FF33')"> [...] </map> <img usemap="#colmap2" src="colortable.gif" border="0" width="289" height="67"></td> <td><input name="tagx" type="text" value="54" size="3" maxsize="3">X Coordinates<br> <input name="tagy" type="text" value="30" size="3" maxsize="2">Y Coordinates</td> </tr> </table> </TD> </TR> </TABLE> </TD> </TR> </TABLE> </TD> </TR> </TABLE> </td> </tr> </table><br /><br /> <div align="center"> <input type="submit" value="Create"> <input type="reset" value="Reset"> </div></TD> </TR> </TABLE> </TD> </TR> </form> I can't seem to figure out how to post a variable to a javascript pop-up window. I'm trying to get a the users input to post directly to the URL. For example: Code: <!--Pop-up--> <script type="text/javascript"> <!-- function expo() { window.open( "export.php?&export=<?PHP $myvar = $_POST['exportthis']; echo $myvar; ?>", "myWindow", "status = 1, height = 300, width = 300, resizable = 0" ) } //--> </script> <form action="" method="post"><input type=text value="pass-this-variable" name="exportthis"> <input type=button value="Export" name="Exp" onClick="expo()"> </form> Any suggestions? I am trying to follow this article on doing a POST request with AJAX and PHP and it works fine, but as soon as I switch from the default submit button to an image I get an error. I would really appreciate any assistance on why switching the submit button to an image would affect it. Thanks http://www.hiteshagrawal.com/ajax/form-post-in-php-using-ajax/comment-page-1 How can I send POST variables to a new window on form submit. I tried the below but what happens is the new window "foo.php" opens but no POST variables are present and also the parent page refreshes when I want it to remain static. Code: <form method="POST" onsubmit="return validateForm(this) && transferListValuesToCSV(document.theForm.box2) && window.open('foo.php', 'foo', 'width=450,height=300,status=yes,resizable=no,scrollbars=no')"; name="theForm" > Situation: adding code to an HTML page that I can add to, but not change any existing code, as it is from a vendor and gets generated on the fly. I need to add a button within the existing <form></form> construct that already has a submit button and the form has an "action=" in it. What I have done is added <input type=button onClick=myscript().... Myscript() opens a .php file as a popup, positions it correctly, and all that. What it doesn't do is move the values to the .php like a method=POST would. Is there anyway to to do this, or do I have to do a set of document.write statements? Existing code: Code: <!-- vendor's untouchable code --> <form method=post name="MainForm" action="xxx.asp?yyy" onsubmit="the_vendors_code();> <input type="text" name="fielda" value="" > <!-- several more fields --> <!-- my code --> <SCRIPT type="text/javascript" SRC="xxx.js"></SCRIPT> <SCRIPT type="text/javascript"> function popupForm(myForm, windowName) { var scrny=0 ; var scrnx=200 <-! code to set scrny and scrnx based on browser --> fielda_h.value = fielda.value ; <!-- etc ..> <!-- here's the place I need help --> newWin= window.open("myPopup.php", windowName, 'height=600,width=550,and a whole bunch of other parameters') ; newWin.moveTo(scrnx, scrny) ; myForm.rel="nofollow" target=windowName; return true ; } </script> <input type="hidden" name="fielda_h" > <input type="button" name="preview" value="See Preview" onClick="popupForm(this, 'join')"/> Note that some of the code was taken from examples found on the net, so there's not a ton of originality here. So, again, just to restate, I know how to do a submit button/form to do action=post, but I am trying to simulate it with a regular button as I cannot change the existing <form></form> construct. Thanks for any and all pointers. Code: <fieldset class="submit" style="padding-left: 200px;"> <?php if ($site_exist >= 1){ echo "<input type=\"submit\" name=\"submit\" value=\"Update\">"; } else { echo "<input type=\"submit\" name=\"submit\" value=\"Submit\">";} ?> <!-- This is the button I am having trouble with. --> <input type="button" name="delete" value="Delete" onClick="return confirmSubmit()"> </fieldset> </form> <script type="text/javascript"><!-- function confirmSubmit(){ var agree=confirm("Are you want to delete this site from our index?"); if (agree) return true ; else return false ; } // --> </script> Not entirely sure which forum this should go in, since the problem could probably be fixed with HTML, PHP or Javascript. Anyway, I have the confirmation window working. What I need is for the button to post a variable (siteDelete = 'true') when it is pressed. I would prefer to do that part without javascript, but I want the data to be posted after and only after the confirmation window returns true. I can do that with a submit button, but I'm not sure what code to use and where to use it when using a non-submit button. Hi all, I'm designing something to addon to an existing product. I'm struggling with some javascript problems. I want to submit a hidden field when you click on an image button, rather than it being an actual submit button. It's going to submit the value "1" to a PHP page, but I don't want it to actually have to GO to the PHP page, just submit it within the webpage. Is this possible? Thanks I had the code working, but something has happened and I can't figure out what the problem is. Could someone please help? Link: http://www.creativeblindsofwilmingto...coverings.html Here's the code I put in the header: Code: script type="text/javascript"> var GB_ROOT_DIR = "http://creativeblindsofwilmington.com/greybox/"; </script> <script type="text/javascript" src="greybox/AJS.js"></script> <script type="text/javascript" src="greybox/AJS_fx.js"></script> <script type="text/javascript" src="greybox/gb_scripts.js"></script> <link href="greybox/gb_styles.css" rel="stylesheet" type="text/css" /> <style type="text/css"> Here's how I coded the links: Code: <a href="http://www.creativeblindsofwilmington.com/images/heartland09.jpg" title="Wood Blind" rel="gb_image[]">Wood</a> <a href="images/everwood02.jpg" title="Faux Wood Blind" rel="gb_image[]">Faux Wood</a> <a href="images/lightlines07.jpg" title="Aluminum Miniblind" rel="gb_image[]">Aluminum</a> <a href="images/discoveries20.jpg" title="Vertical Blinds" rel="gb_image[]">Vertical</a> |