JavaScript - Window Open Method=post
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. Similar TutorialsHi, In my "main.js" file I need to create a new window with a button. If the button clicked a function in the "main.js" file is called. I tried the following, but new window does not see the function in the "main.js" file. function create_new_window() { my_window = window.open ("","mywindow1","status=1,width=350,height=150"); my_window.document.write('<H1>My Window ...</H1>'); my_window.document.write('<form><input type="button" value="Submit" onClick="submitData();"/></form>'); .... } function submitData() { ... } window.open() doesn't open an entirely new window in FF3.6, just a new tab suggestions? Edit: Yeah, ok, so if i specify a size smaller than the current standard window, it'll be forced to open a new window. but what if i want a new standard sized window to open entirely? and in any case, i wan t amore direct solution where possible, thanks. Hi Ive found out how to force another browser window to open at a certain size when a link is clicked. Here's the whole line of code including the layer, the javascript and the image, <div id="Layer6" style="position:absolute; width:10px; height:8px; z-index:6; left: 561px; top: 310px"><a href="javascript:;" onClick="MM_openBrWindow('navigation%20instructions.htm','','width=50,height=50')"><img src="images/info.gif" width="15" height="15" border="0"></a></div> How do I adapt this so I can also specify the x&y co-ordinates of the opened window relative to the window that launched it. thanks alot Masten I am using a window.open to trigger a mailto: command. I don't want the window to stay open so I try to close it right after. The default email client launches correctly, but the window stays open and I get the following Javascript error: Unable to get value of the property 'close': object is null or undefined Code: Code: var win = window.open(mailto_link,'emailWindow'); win.close(); I do write some php, but have not much idea about JavaScript. I use window.open to open 10 pages simultaneously. I prefer to open them with a time delay from each other to put less load on the target server. This is my code with no delay. (I played around with setTimeout but can't get it to work.) PHP Code: <a href='http://www.".$new[9]."' onclick="window.open('http://www.".$new[0]."/'); window.open('http://www.".$new[1]."/'); window.open('http://www.".$new[2]."/'); window.open('http://www.".$new[3]."/'); window.open('http://www.".$new[4]."/'); window.open('http://www.".$new[5]."/'); window.open('http://www.".$new[6]."/'); window.open('http://www.".$new[7]."/'); window.open('http://www.".$new[8]."/')\" target='new300/'>Open 10</a> Hey peeps, I'm trying to use wget to access this website that uses javascript. The website is from my work. Basically I made a program that parses information from our payment page. It tells me how much I am being paid for the month. Anywho, the variables on the page are in javascript, and thats one language I'm not proficient at. I need to change the month that it gets the pay for. The default is the current month. But it can be changed to last month, and from the code I can tell that something has to be changed from "THIS_MONTH" to "LAST_MONTH", but I'm not sure how to properly do it. Posted below is the source code from the website. Please let me know how I can change that without actually having to click the button to change the scope to last month. And also, is there any way to change this in the post method, or any other method that wget uses? I only included the parts I thought could be relevant. Thanks guys! BTW, I think it pertains with g_FiltersMenuStr Code: <title>SupportSpace - Tech Support for Computers, Printer, Security, Gadgets...</title> <meta name = "description" content = "get immediate tech support for your PC / Computer, Printers, Outlook / Email Setup, Wireless, Networking, Anti-Virus & Security, Spyware, XP, Vista, I-Pod, MP3 Player Setup, Zune, Printer Setup, Backup Services for your Documents & Many other online live support"/> <meta name = "keywords" content = "online live tech support PC Computer Printers Outlook Email Setup Wireless Networking AntiVirus Security Spyware XP Vista IPod MP3 Player Zune Printer Setup Backup Services hardware software help chat"/> <meta name = "language" content = "English"/> <link REL="SHORTCUT ICON" HREF="/support/images//icons/shortcut_icon.ico"/> <script type="text/javascript">if(!JAWR){var JAWR = {};};;JAWR.jawr_dwr_path='/support/dwr';JAWR.dwr_scriptSessionId='CCA333F742C70F495236AA2C97D653D2';JAWR.app_context_path='/support';</script> <link rel="stylesheet" type="text/css" media="screen" href="/support/styles/31289092/bundles/common_connection.css" /> <link rel="stylesheet" type="text/css" media="screen" href="/support/styles/1893248551/bundles/sessionHistory.css" /> </head> <script type="text/javascript">if(!JAWR){var JAWR = {};};;JAWR.jawr_dwr_path='/support/dwr';JAWR.dwr_scriptSessionId='BF92335E3E86FC7586F1F5BFB96E81FB';JAWR.app_context_path='/support';</script> <script type="text/javascript" src="/support/scripts/122785183/bundles/common.js" ></script> <body class="supportspace"> <script type="text/javascript"> var jabberConnectorSrc = "/support/extra_scripts/1.23a1.6/flashconnector/jabberConnector.swf"; if (!!(window.attachEvent && !window.opera)){ document.write('\ <OBJECT id="jabberConnector" dontRewriteMe=true codeBase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" height="1" width="1" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000">\ <PARAM value="'+jabberConnectorSrc+'" name="Src" />\ </OBJECT>'); } else{ document.write('<embed swliveconnect="true" name="jabberConnector" id="jabberConnector" src="'+jabberConnectorSrc+'" quality=low height="1" width="1" type="application/x-shockwave-flash"></embed>'); } </script> <!--[if lt IE 7]> <style> #dSSLogo{position:relative} </style> <![endif]--> <div id="dHeader"> <div id="dHeader_1" class="center s2DarkGray"> <div id="dSSLogo" onclick="document.location = 'http://www.supportspace.com/support/'"></div> <div class="rightLinks"> <div id="dHeaderLinks" style='display:none;' class='invisible'> <div class="dHeaderLink"><a class="mainlevel-trans" href="javascript:void(0);" id="dSigninMenu">Sign In</a></div> <div class="dHeaderLinksSep">|</div> <div class="dHeaderLink"><a class="mainlevel-trans" href="https://www.supportspace.com/support/affiliates.s2?aiu=UserRegistration" id="headerSecondMenu">Register</a></div> <div class="dHeaderLinksSep">|</div> <div class="dHeaderLink"><a class="mainlevel-trans" href="http://corporate.supportspace.com/about_us">About Us</a></div> <div class="dHeaderLinksSep">|</div> <div class="dHeaderLink"><a class="mainlevel-trans" href="http://www.supportspace.com/support/faq.s2" id="menuHelp">Help</a></div> </div> <div id="dHeaderLinksAfterLogin" class='visible'> <div id="dHeaderMailNotification"> <a id="nomailNotification" class="s2LightGray nounderline" href="http://www.supportspace.com/support/inbox.s2">(<span class="nbNewOfflineMessagesHeader">0</span>) <img src="/support/images/offline_messages/message_icon_grey_16x14.gif" alt="" title="" width="16" height="14" align="absmiddle" border="0"/></a> <a id="mailNotification" style="display:none" class="s2Blue nounderline" href="http://www.supportspace.com/support/inbox.s2">(<span class="nbNewOfflineMessagesHeader">0</span>) <img src="/support/images/offline_messages/message_icon_blue_16x14.gif" alt="" title="" width="16" height="14" align="absmiddle" border="0"/></a> </div> <div id="dHeaderWelcome" class="dHeaderWelcome">Hello </div> <div style="float:left;"> <table cellpadding=0 cellspacing=0 border=0> <tr> <td width="5">|</td> <td> <a id="dMySpaceMenu" class="mainlevel-trans" href="#">My Account</a> <ul id="dMySpaceMenuContent" class="menu" style="display:none;"></ul> </td> <td width="5">|</td> <td><a id="dSignOut" class="mainlevel-trans" href="http://www.supportspace.com/support/j_spring_security_logout">Sign Out</a></td> <td width="5">|</td> <td><a class="mainlevel-trans" href="http://corporate.supportspace.com/about_us">About Us</a></td> <td width="5">|</td> <td><a id="menuHelpAfter" class="mainlevel-trans" href="http://www.supportspace.com/support/faq.s2">Help</a></td> </tr> </table> </div> </div> </div> <div style="clear:both;"></div> </div> <div id="dHeader_2" class="center"> <div id="dHeaderMenus"> <div> <a href="http://www.supportspace.com/support/" onclick="this.blur()" title="SupportSpace homepage" tabindex="1" id="menuHome"> <img src="/support/images/header/home_btn_regular.gif" alt="" width="127" height="32"/> </a> </div> <div> <a href="http://www.supportspace.com/support/expert" onclick="this.blur()" id="menuExperts" title="Search for online experts"> <img src="/support/images/header/experts_btn_regular.gif" alt="" width="127" height="32"/> </a> </div> <div> <a href="http://www.supportspace.com/support/services" onclick="this.blur()" id="menuPackages" title="Search for featured support services"> <img src="/support/images/header/services_btn_regular.gif" alt="" width="127" height="32"/> </a> </div> </div> <div id="dSearchBox"> <div id="dSearchBoxQuery"> <input type="text" id="searchBoxQuery" style="color:#7C7C7C" name="searchBoxQuery" value="Search" onkeypress="submitEnter(this,event,runExternalSearch)"> </div> <div id="dSearchBoxGo"> <img id="dSearchBoxGoBtn" width="22" height="22" border="0" alt="Search" src="/support/images/header/search_icon_regular_22x22.gif" onmouseout="this.src='/support/images/header/search_icon_regular_22x22.gif'" onmouseup="this.src='/support/images/header/search_icon_regular_22x22.gif'" onmouseover="this.src='/support/images/header/search_icon_mouse_over_22x22.gif'" onmousedown="this.src='/support/images/header/search_icon_pressed_22x22.gif'" /> </div> <div style="clear:both;"></div> </div> </div> <div class="clearboth"></div> </div> <div id="dTemplateBody" class="center"> <table border="0" cellpadding="0" cellspacing="0"> <tr> <td class="leftPanel" > <div > <div class="getHelp box"> <div class="title"><img src="/support/images/header/menu_get_help.gif" width="170" height="27" alt="Get help on products"></div> <div class="s2Gray productList content"> <ul> <li class="product ellipsis"><a class="linkOnHover" href="http://www.supportspace.com/support/category/Virus_-_Spyware" title="Virus - Spyware">Virus - Spyware</a></li> <li class="product ellipsis"><a class="linkOnHover" href="http://www.supportspace.com/support/category/Printers" title="Printers">Printers</a></li> <li class="product ellipsis"><a class="linkOnHover" href="http://www.supportspace.com/support/category/PC_Support" title="PC Support">PC Support</a></li> <li class="product ellipsis"><a class="linkOnHover" href="http://www.supportspace.com/support/category/Windows" title="Windows">Windows</a></li> <li class="product ellipsis"><a class="linkOnHover" href="http://www.supportspace.com/support/category/Security" title="Security">Security</a></li> <li class="product ellipsis"><a class="linkOnHover" href="http://www.supportspace.com/support/category/Backup" title="Backup">Backup</a></li> <li class="product ellipsis"><a class="linkOnHover" href="http://www.supportspace.com/support/category/PC_to_PC_Transfer" title="PC to PC Transfer">PC to PC Transfer</a></li> <li class="product ellipsis"><a class="linkOnHover" href="http://www.supportspace.com/support/category/Wireless_Network" title="Wireless Network">Wireless Network</a></li> <li class="product ellipsis"><a class="linkOnHover" href="http://www.supportspace.com/support/category/Email_and_Internet" title="Email and Internet">Email and Internet</a></li> <li class="product ellipsis"><a class="linkOnHover" href="http://www.supportspace.com/support/category/Browsers" title="Browsers">Browsers</a></li> <li class="product ellipsis"><a class="linkOnHover" href="http://www.supportspace.com/support/category/iPod_and_MP3" title="iPod and MP3">iPod and MP3</a></li> <li class="product ellipsis"><a class="linkOnHover" href="http://www.supportspace.com/support/category/Camera_-_Photo" title="Camera - Photo">Camera - Photo</a></li> <li class="product ellipsis"><a class="linkOnHover" href="http://www.supportspace.com/support/category/Mobile_Phones" title="Mobile Phones">Mobile Phones</a></li> <li class="product ellipsis"><a class="linkOnHover" href="http://www.supportspace.com/support/category/Green_PC" title="Green PC">Green PC</a></li> </ul> </div> </div> <div class="box howdoesitwork s2Gray"> <div class="title"> <img src="/support/images/left_pannel/menu_how_it_works_170x43.gif" width="170" height="43" alt=" "> </div> <div class="steps"> <table width="100%" cellpadding="0" cellspacing="0"> <tr> <td><img src="/support/images/left_pannel/3_steps_1_icon_55x60.gif" width="55" height="60" alt=""/></td> <td valign="top"> <p><span class="title bold">1.Choose</span><br/> a service or an online expert.</p> </td> </tr> <tr height="5"></tr> <tr> <td><img src="/support/images/left_pannel/3_steps_2_icon_55x60.gif" width="55" height="60" alt=""/></td> <td valign="top"> <p><span class="title bold">2.Connect</span><br/> to the expert and watch your problem being solved.</p> </td> </tr> <tr height="5"></tr> <tr> <td><img src="/support/images/left_pannel/3_steps_3_icon_55x60.gif" width="55" height="60" alt=""/></td> <td valign="top"> <p><span class="title bold">3.Done</span><br/> Relax and rate your experience.</p> </td> </tr> </table> </div> </div> </div> </td> <td class="panelSpacer" > </td> <td class="rightPanel" > <div id="dBodyPage" class="bodyPage" > <script type="text/javascript" src="/support/scripts/N1461701270/bundles/session_history.js" ></script> <script type="text/javascript"> var gExternalParameterType = ""; var gSupportSessionId = ""; var gIsSupporter = true; var gError = false; var gExternalSessionFatalError = true; var gDefaultFilterList = {}; gDefaultFilterList['SESSION_DATE'] = ""; gDefaultFilterList['SESSION_STATUS'] = ""; gDefaultFilterList['SESSION_TYPE'] = ""; gDefaultFilterList['SUPPORT_SESSION'] = ""; gDefaultFilterList["SESSION_DATE"] = "THIS_MONTH"; gDefaultFilterList["SESSION_TYPE"] = "PAID"; var gSHistoryStrings = { error_feedback_add:"You cannot add feedback to this session.", error_feedback_fatal:"Required session is not availible. You cannot add feedback.", error_session_report_add:"You cannot edit the solution report for this session.", error_session_report_fatal:"Required session is not available. You cannot edit the solution report." } var g_FiltersMenuStr = { "SESSION_DATE":"Date", "SESSION_DATE.TODAY":"Today", "SESSION_DATE.YESTERDAY":"Yesterday", "SESSION_DATE.THIS_WEEK":"This week", "SESSION_DATE.LAST_WEEK":"Last week", "SESSION_DATE.THIS_MONTH":"This Month", "SESSION_DATE.LAST_MONTH":"Last month", "SESSION_DATE.LAST_6_MONTH":"Last 6 months", "SESSION_DATE.THIS_YEAR":"This year (2011)", "SESSION_DATE.LAST_YEAR_AND_EARLIER":"Earlier than (2011)", "SESSION_STATUS":"Status", "SESSION_STATUS.UNRESOLVED":"Unresolved", "SESSION_STATUS.ENDED_BEFORE_PAYMENT":"Ended before payment", "SESSION_STATUS.FORWARDED":"Forwarded", "SESSION_STATUS.DISPATCHED":"Dispatched", "SESSION_STATUS.RESOLVED":"Resolved", "SESSION_STATUS.UNCOMPLETED":"Uncompleted", "SESSION_STATUS.IN_PROGRESS":"In progress", "SESSION_STATUS.LEFT_OPEN":"Left Open", "SESSION_TYPE":"Type", "SESSION_TYPE.PAID":"Paid", "SESSION_TYPE.FREE_COUPON":"Free (Coupon)", "SESSION_TYPE.FREE_EXPERT":"Free (Expert)", "SUPPORT_SESSION":"Current Support Session", "DEFAULT_FILTER_MENU":"Back to default", "NO_FILTERS_MENU":"Clear all filters", "NO_FILTERS_NOTE":"No filters (All sessions)" }; var gSessionFeedbackHistoryUrl = "/support/sessionFeedbackHistory.s2"; var gSessionHistory = "/support/sessionHistory.s2"; var gSessionHistoryUrls = { filter_empty:"http://images.supportspace.com/support/images/common/empty.gif", filter_X:"http://images.supportspace.com/support/images/session_history/filter_X_mark.gif", filter_V:"http://images.supportspace.com/support/images/session_history/filter_V_select.gif", filter_arrow_white:"http://images.supportspace.com/support/images/session_history/filter_arrow_white.gif", filter_arrow_grey:"http://images.supportspace.com/support/images/session_history/filter_arrow_grey.gif" } var g_experts; </script> <div id="dSHistoryPage"> <div class="dSmallPreloaderContainer"><div id="dSmallPreloader" style="display:none;"><img src="http://images.supportspace.com/support/images//common/preloader_16x16.gif" alt=""></div></div> <h1 style="float:left">Session History</h1> <div class="clearboth"></div> <div id="dSHistoryContent"> <div id="dListBar" class="listBar"> <div id="dFiltersMenuButton">Filtered by: <img src="/support/images/session_history/filter_arrow_down.gif" alt=""/></div> <div id="dFiltersSelected"></div> <div class="displayedCounter">Displaying: 38</div> </div> <div id="dFiltersMenuContent"><div id="dFiltersMenuDivToReplace"></div></div> <div class="clearboth"></div> <div id="dSHistoryResults"> <script type="text/javascript"> var gSelectedFilters = {}; gSelectedFilters['SESSION_DATE'] = ""; gSelectedFilters['SESSION_STATUS'] = ""; gSelectedFilters['SESSION_TYPE'] = ""; gSelectedFilters['SUPPORT_SESSION'] = ""; gSelectedFilters["SESSION_DATE"] = "THIS_MONTH"; gSelectedFilters["SESSION_TYPE"] = "PAID"; (function(){ var dDisplayedCounter = $("dListBar") ? $("dListBar").down(".displayedCounter") : null; if(dDisplayedCounter){ dDisplayedCounter.update("Displaying: 38"); } }).defer(); var gSolutionReport; </script> <div class="dThreads"> <div id="dSessionHistoryError" style="display:none;"></div> <script type="text/javascript"> if (typeof(window.g_experts) == "undefined" || !window.g_experts){ window.g_experts = []; window.gIsAnExpertIsOnline = false; } g_experts.push({ id:193037, supporterDynamicDetails:{ online4Customer:{ customer:{ id:"" }, customerCookie:"" }, supporterDisplayPresenceStatusForExpectedCustoemr:"online", supporterDisplayPresenceStatus:"online" }, displayUserName:"", jabberUsername:"23a9ea173c4a7923ef41c9d6afa208d36ea1900f", photoUri:"193037_1273126504113.gif" }); </script> Dear forum guys, I'm having a problem regarding the POST method with Ajax. I'm sending form inputs through Ajax by POST method to an ASP file to add them back to a database. However, what i noticed is that whenever i send the inputs of the form let's say ("username") through Ajax by the POST method, the result is the input "username" however with no spaces. Why is it that the Ajax POST method ignores the spaces and sends the inputs without the spaces? I tried it with the GET method and found out that GET doesn't ignore the spaces, it worked. But the application that i'm trying to build requires sending bigger data that the GET method can't send. SO therefore i need the POST method but i ran into the problem of Spaces Being Ignored. Please, is there a way to send any string that contains spaces through AJAX POST method and not ignore the spaces in the output??? Thank You David +++++++++++++++++++++++++++first window+++++++++++++++++++++++++ <html> <head> <script language="javascript"> var myWindow; function christDoes(){ mydWindow=open("second.html", "yes"); } </script> </head> <body><form name="myform" method=POST ACTION="sake.html" ><CENTER> <B>ENTER YOUR SUBJECT</B><INPUT TYPE="TEXT" NAME="subject"> <input type="button" name="ok" value="OK" onClick="christDoes()"> </form> </body> </html> +++++++++++++++++++++++++++parent window+++++++++++++++++++++++++ ++++++++++++++++++++++++++++child window++++++++++++++++++++++ <html> <head> <script language="javascript"> function me(){ displayColor(); } function displayColor() { callWindow=window.open("third.html","fine"); } var m=0; var fSubject = self.opener.document.forms[0].subject.value; if(fSubject.length>0){ if(isNaN(fSubject)){fSubject="";} else{opener.alert("Please enter figure");} numSub=parseInt(fSubject); if(numSub==2){var strSub="ab";} self.document.write("<center>" +"ENTER SUBJECT HERE" +"</center><br>"); var mercy="<HTML><BODY>" mercy +="<FORM ACTION='save.html' METHOD='POST'>" mercy +="<CENTER>" sub=new Array(strSub.length); for(var i=0; i<sub.length; i++){ m++; mercy +=m +"<input type='text' name='sub[i].toLowerCase()'>" +"<BR>"; opener.alert("You have entered" +m +"subjects"); } } mercy +="</CENTER></FORM></BODY></HTML><BR></BR>"; self.document.write(mercy +"<BR>"); self.document.bgColor="pink"; self.document.write("<center>" +"<input type='button' name='submit' value='SUBMIT'>" +"<center>"); } </script> </head> <body onload='me()'> </body> </html> ++++++++++++++++++++++++++++++child window++++++++++++++++++++ +++++++++++++++++++++++++++++++new window+++++++++++++++++++++ <html> <head> <script language="javascript"> function help(){ self.document.write("this is me") self.document.write("<center>" +"<input type='button' name='submit' value='SUBMIT'>" +"<center>"); } </script> </head> <body onLoad="help"> </body> </html> +++++++++++++++++++++++++++++++new window+++++++++++++++++++++ Can somebody help me with the code to make this button work? In the parent window when 2 is input in the textbox and 'OK' button clicked, the second window opens with 2 textbox and 'SUBMIT' button. If 'SUBMIT' button is clicked in the child window i want it to open the new window. Please help me out. Thanks. God bless in Jesus name. +++++++++++++++++++first window+++++++++++++++++++++++++ <html> <head> <script language="javascript"> var myWindow; function christDoes(){ mydWindow=open("second.html", "yes"); } </script> </head> <body><form name="myform" method=POST ACTION="sake.html" ><CENTER> <B>ENTER YOUR SUBJECT</B><INPUT TYPE="TEXT" NAME="subject"> <input type="button" name="ok" value="OK" onClick="christDoes()"> </form> </body> </html> +++++++++++++++++++first window+++++++++++++++++++++++++ +++++++++++++++++++second window++++++++++++++++++++++ <html> <head> <script language="javascript"> function me(){ displayColor(); } function displayColor() { callWindow=window.open("third.html","fine"); } var m=0; var fSubject = self.opener.document.forms[0].subject.value; if(fSubject.length>0){ if(isNaN(fSubject)){fSubject="";} else{opener.alert("Please enter figure");} numSub=parseInt(fSubject); if(numSub==2){var strSub="ab";} self.document.write("<center>" +"ENTER SUBJECT HERE" +"</center><br>"); var mercy="<HTML><BODY>" mercy +="<FORM ACTION='save.html' METHOD='POST'>" mercy +="<CENTER>" sub=new Array(strSub.length); for(var i=0; i<sub.length; i++){ m++; mercy +=m +"<input type='text' name='sub[i].toLowerCase()'>" +"<BR>"; opener.alert("You have entered" +m +"subjects"); } } mercy +="</CENTER></FORM></BODY></HTML><BR></BR>"; self.document.write(mercy +"<BR>"); self.document.bgColor="pink"; self.document.write("<center>" +"<input type='button' name='submit' value='SUBMIT' onClick='window.open('third.html', '')'>" +"<center>"); } </script> </head> <body onload='me()'> </body> </html> ++++++++++++++++++++++second window++++++++++++++++++++ ++++++++++++++++++++++third window+++++++++++++++++++++ <html> <head> <script language="javascript"> function help(){ self.document.write("this is me") self.document.write("<center>" +"<input type='button' name='submit' value='SUBMIT'>" +"<center>"); } </script> </head> <body onLoad="help"> </body> </html> ++++++++++++++++++++++third window+++++++++++++++++++++ Can somebody help me with the code to make this button work? In the parent window when 2 is input in the text box and 'OK' button clicked, the second window opens with 2 text box and 'SUBMIT' button. If 'SUBMIT' button is clicked in the child window i want it to open the third window. Please help me out. Thanks. God bless in Jesus name. *ADDED* Though i am advised to add 'window .open' as one of the arguments to the OK button which i did yet it doesn't work somebody please help me out! I am using Mozilla 3.6 could this mean that it doesn't support this? Hi to all, I have a dynamic form, when a button is clicked 3 more fields appear, the function is to colect for example from date [02/02/2010] to date [10/02/2010] equals price [250$] per week and if you want another period just click the button and 3 more fields appear. How do I get all this data to PHP? Code: <script type="text/javascript"> var counter = 3; function addNew() { // Get the main Div in which all the other divs will be added var mainContainer = document.getElementById('mainContainer'); // Create a new div for holding text and button input elements var newDiv = document.createElement('div'); // Create a new text input var newText = document.createElement('input'); newText.type = "text"; newText.value = "DD/MM/AAAA"; newText.name = counter++; var newText1 = document.createElement('input'); newText1.type = "text"; newText1.value = "DD/MM/AAAA"; newText1.name = counter++; var newText2 = document.createElement('input'); newText2.type = "text"; newText2.value = "0"; newText2.name = counter++; // Create a new button input var newDelButton = document.createElement('input'); newDelButton.type = "button"; newDelButton.value = "Delete"; // Append new text input to the newDiv newDiv.appendChild(newText); newDiv.appendChild(newText1); newDiv.appendChild(newText2); // Append new button input to the newDiv newDiv.appendChild(newDelButton); // Append newDiv input to the mainContainer div mainContainer.appendChild(newDiv); counter++; // Add a handler to button for deleting the newDiv from the mainContainer newDelButton.onclick = function() { mainContainer.removeChild(newDiv); } } </script> <table style="margin-left:200px" border="0"> <tr><!-- Row 1 --> <td width="140"><b>Start Date</b></td><!-- Col 1 --> <td width="142"><b>End Date</b></td><!-- Col 2 --> <td width="140"><b>Price per week</b></td><!-- Col 3 --> </tr> </table> <div style="margin-left:200px" id="mainContainer"><div><input value="DD/MM/AAAA" name="0" type="text" ><input value="DD/MM/AAAA" name="1" type="text" ><input value="0" name="2" type="text" ><input type="button" value="New price" onClick="addNew()"></div> Hi I'm new here and need some help; I spent so long with this and need either a miracle or a javascript expert! I have the code below which is used to open up a chat window, the problem is all browser treat this as a pop up and block it! What could be changed to get round this? $chat = "window.open( '" . SK_Navigation::href("private_chat", array("userKey"=>$pr_key, "oppUserKey"=>$opp_key, 'is_esd_session'=>1 )) . "', '', 'height=540,width=415,left=100,top=100,scrollbars=no,resizable=no' );"; Thanks dr Hi Folks, here is the weirdest problem. I want open a url in the same window, replacing the current page. To test this I have created a simple script. The setup: I have two files in the same folder. abc.html and xyz.html. abc.html contains a button that calls this script: Code: function openWindow() { window.open( "xyz.html" ) ; } And this works fine, just as a test. But I want to open xyz.html in the same window, replacing abc.html . So I try: Code: window.open( "xyz.html" , "_self" ) ; does not work but simply reloads abc.html. I try: Code: window.location.href = "xyz.html"; does not work, but, again, simply reloads abc.html. What gives? The odd thing is, when it reloads the same page, abc.html, the address bar displays this at the end of the address: abc.html?button=Submit Any ideas on what may be going wrong here, or how I can get this to work? All this is being tested locally on my laptop - MacBook - and have tested in Safari and Firefox with the same results for both. Thanks in advance! Code: <a href=" javascript: myWindow = window.open('http://en59.tribalwars.net/game.php?village=3463&screen=premium&mode=transfer'); myWindow.document.forms[0].name.value='Gods Child';end" target="_blank">Donate Please</a> So, what I am trying to do is when you click the link, a new page opens to that site, then does document.forms[0].name.value='Gods Child'; I can get the page to open, but then it doesn't do the second part. If I run the second part in the url bar, when at the other site, it works how I want too, but not when I do it at the same time. NOTE: The only part that needs to be in this is document.forms[0].name.value='Gods Child'; and the link, but you can change the rest however you want. when a user click on a link, it would open a new window in HTML it is something like this: Code: <a href="http://google.com" target="_blank">click here</a> How do I do this in Javascript? So a user would click on the link and it would open a new window. Here's my code Code: document.writeln('<tr><td>' + "http://google.com" + '</td></tr>'); I know window.open(url) would open a new window, but how do I make it clickable?? Any comments or suggestion would be greatly appreciated. thanks Hello, I want to know how to open a new window when someone is closing a page. I mean for example, I have to two pages, if the user closes the first page when he clicks on Close button or close in his tab, a new window will open to open the second page. Thank you.
Code: <SCRIPT language=JavaScript> function DoSearch() { if (document.frmSearchID.txtIssueID.value != "") { if (isNaN(document.frmSearchID.txtIssueID.value)) { alert('Issue Numbers must be numeric');} else {document.location = "http://www.****.com/Apps/AddIssues/EditIssue.asp?IssueID=" + document.frmSearchID.txtIssueID.value + "&ProjectID=LRUSTARS";}}} </SCRIPT> <FORM style="display:inline" target="_blank" action="http://www.****.com/default.asp?ProjectID=LRUSTARS#" name="frmSearchID" onSubmit="javascript:DoSearch();return false;" method="post"> <INPUT class="formField1" name="txtIssueID"> <INPUT class="formBox" onClick="javascript:DoSearch(); return false;" type="submit" name="search" VALUE="Search"> </form> Cant seem to get it to open in a new window any help? Hi All: I have a problem with a free script for an internal site search and I would like to tweek. I know nothing about javascript so be patient. What I want to do is to open a new window when you select a hyperlink in the results returned page. Here's the relevant code: Code: // ---------- script properties ---------- var include_num = 1; var bold = 0; // ---------- sites ---------- var s = new Array(); s[0] = "JSE^form.html^Enter JSE in the example above ...^open source, free, client side"; s[1] = "JSE DOCUMENTATION^doc.txt^JSE is a client-side local site search engine. Written entirely in JavaScript 1.3 it works with browsers from Netscape 4.7 to Microsoft Internet Explorer 6.0 ...^ faq, docs, instructions"; // ---------- end of script properties and sites ---------- var cookies = document.cookie; var p = cookies.indexOf("d="); if (p != -1) { var st = p + 2; var en = cookies.indexOf(";", st); if (en == -1) { en = cookies.length; } var d = cookies.substring(st, en); d = unescape(d); } var od = d; var m = 0; if (d.charAt(0) == '"' && d.charAt(d.length - 1) == '"') { m = 1; } var r = new Array(); var co = 0; if (m == 0) { var woin = new Array(); var w = d.split(" "); for (var a = 0; a < w.length; a++) { woin[a] = 0; if (w[a].charAt(0) == '-') { woin[a] = 1; } } for (var a = 0; a < w.length; a++) { w[a] = w[a].replace(/^\-|^\+/gi, ""); } a = 0; for (var c = 0; c < s.length; c++) { pa = 0; nh = 0; for (var i = 0; i < woin.length; i++) { if (woin[i] == 0) { nh++; var pat = new RegExp(w[i], "i"); var rn = s[c].search(pat); if (rn >= 0) { pa++; } else { pa = 0; } } if (woin[i] == 1) { var pat = new RegExp(w[i], "i"); var rn = s[c].search(pat); if (rn >= 0) { pa = 0; } } } if (pa == nh) { r[a] = s[c]; a++; } } co = a; } if (m == 1) { d = d.replace(/"/gi, ""); var a = 0; var pat = new RegExp(d, "i"); for (var c = 0; c < s.length; c++) { var rn = s[c].search(pat); if (rn >= 0) { r[a] = s[c]; a++; } } co = a; } function return_query() { document.jse_Form.d.value = od; } function num_jse() { document.write(co); } function out_jse() { if (co == 0) { document.write('Your search did not match any documents.<p>Make sure all keywords are spelt correctly.<br>Try different or more general keywords.'); return; } for (var a = 0; a < r.length; a++) { var os = r[a].split("^"); if (bold == 1 && m == 1) { var br = "<b>" + d + "</b>"; os[2] = os[2].replace(pat, br); } if (include_num == 1) { document.write(a + 1, '. <a href="', os[1], '">', os[0], '</a><br>', os[2], '<p>'); } else { document.write('<a href="', os[1], '">', os[0], '</a><br>', os[2], '<p>'); } } } You can see the search feature in action at http://qualityhealthplans.com It works great but I want to be able to select a particular page hyperlink and open it in a new window without leaving the search results page. Can anyone help? Hi all, I found this bookmarklet which I'm using in Firefox. Would anyone here be willing to modify it to display its results in a new tab, instead of using the current tab? Thanks in advance. Code: javascript:q=""+(window.getSelection?window.getSelection():document.getSelection? document.getSelection():document.selection.createRange().text);if(!q) q=prompt("Search terms [leave selection and box blank to list all pages] ...").replace(/\s\+/g,"%252B");if(q!=null)location="http://www.google.com /search?q="+q.replace(/\s+/g,"+")+"+site:"+location.hostname;void(0); Hi all, im sure this will be pretty simple, at the moment i have some code which sends text from a textarea to a php file, the php file then stores the data into a database. the javascript post is as follows: Code: var text = document.getElementById(area).value; http.open('post', 'autosave.php?text='+text); there is a little bit more to this(just a handle response). My issue is that when the data is passed through javascript newlines and breaks disappear, so when i call the saved data it is presented as one long string with no formatting. i tried the nl2br() function and htmlspecialchars() function in the php file that the javascript passes the data to, this made no difference. I then tried to replace /n with <br /> in the javascript before passing the text variable again this made no differnce. Does anyone have any ideas how to keep formatting during this process? Hello everyone, i kinda stuck at this point on my php script, it has this javascript code and i stuck there Line 16: Code: echo("<script language=\"JavaScript\">\nfunction openptc(tpge,pnme,w,h){\nsettings=\"width=\" + w + \",height=\" + h + \",scrollbars=yes,location=no,directories=no,status=1,menubar=no,toolbar=no,resizable=no\";\nwindow.open(tpge,pnme,settings);\n}\n//-->\n</script>"); Line 72: Code: print "<td><a href=\"#\" onClick=\"openptc('./paidtoclick.php?adid=$row[linkid]&action=start&".session_name()."=".session_id()."','PaidtoClickPage','640','480');\"><b>Click Here To View</b></a><tr>"; I think those 2 lines actually are my problem I hope you won't get stuck because it's php and javascript and html. This code makes the site open in a new pop up window. how to make it open in a new tab |