JavaScript - Submit Problem.
Hi basically i have this invite code which when a member copy and pastes the javascript code into browser it auto selects all friends and send an invite.
The problem is that the user has to do this manually, is there a way i can create a clickable button which when they click it automatically pastes the code i want into browser and submits? Thanks. Similar TutorialsHi there, Our development team created a page using JS to submit a form. It works fine in IE6... but not in IE8 nor FF3. They can't seem to detect why, so I'm posting this in the hopes that someone will be able to let me know... so that I can tell them. Man! Here is the code that they use: Code: function doSubmit() { var form = document.RegistrationForm; form.actionType.value = "userInfo"; form.action = "/fdl/benefitsmanager/registration/UserInfoSubmit.do"; var prefix = document.getElementById('userInfo.prefix')[document.getElementById('userInfo.prefix').selectedIndex].text; var suffix = document.getElementById('userInfo.suffix')[document.getElementById('userInfo.suffix').selectedIndex].text; document.getElementById('userInfo.prefixString').value = prefix; document.getElementById('userInfo.suffixString').value = suffix; form.submit(); } It's called by clicking the below image: Code: <a href="javascript:doSubmit();"><img src="../images/buttons/submit.gif" alt="Submit" width="108" height="23" border="0"></a> The above code works fine in IE6 and lets the user submit the form. However, in FF3 nothing happens when the image is clicked and I get the following error using Firebug: document.getElementById("userInfo.prefix") is null var prefix = document.getElementById(...rInfo.prefix').selectedIndex].text; And in IE8 nothing happens when the image is clicked and it just tells me that there is an error. I don't have access to the code, so I can't play around with manipulating the JS. Darn! However, can anyone see what might be causing the error in modern browsers? I'm a bit surprised it's IE8 and FF3 that are having issues... as IE6 is normally the least forgiving browser. Thanks so much, CO I hope someone can help with this. I needed a form for my website and found one i liked so used there code, however i cannot get mine to work properly, i believe the problem exists here, however not sure what to do with it: <form action="contact.htm" method="post" name="contactForm" onsubmit="return validateForm()" > <p><strong>Contact information: </strong></p> <input type=hidden name="httpref" value="http://www.karenshealthandfitness.com/contact.htm"> also do i need a php file with this or something along those lines? Sorry if that sound lame, i am not the greatest at this just fumble my way through. I have a simple js script which toggles between 2 tabs using a simple switch function to display: block or none. In each tab I have a form which returns data from a db using php mysql. The problem is that when I click the submit button the page is reloaded and so the page reverts to showing the 1st tab. The data is returned correctly but the users has to click the 2nd tab to view it. I have tried adding on onclick event to the submit button but this doesn't work. Is it possible to force the 2nd tab to show if the submit button in the 2nd tab is clicked. Many thanks! Hello everyone, I have a webpage with three different search options. Each option has a radio button clicking on which enables the text fields and buttons in that option with the help of java script. The first options allows to search by PIN. Second one by SSN, DOB and DOBRange, And 3rd one by various combinations of the name. The javascript I use to do this is given below: Code: function chMd() { // initialize form with empty field document.forms[0].PIN.disabled=false; document.forms[0].PIN.value=""; document.forms[0].SSNfirst.disabled=false; document.forms[0].DOBRange1.disabled=false; document.forms[0].DOBRange1.value=""; document.forms[0].DOBRange2.disabled=false; document.forms[0].DOBRange2.value=""; document.forms[0].LastName.disabled=false; document.forms[0].LastName.value=""; document.forms[0].FirstName.disabled=false; document.forms[0].FirstName.value=""; document.forms[0].MiddleName.disabled=false; document.forms[0].MiddleName.value=""; document.forms[0].Last4.disabled=false; document.forms[0].Last4.value=""; document.forms[0].First4.disabled=false; document.forms[0].First4.value=""; document.forms[0].DOB1.disabled=false; document.forms[0].DOB2.disabled=false; document.forms[0].Option1.disabled=false; document.forms[0].Option2.disabled=false; document.forms[0].Option3.disabled=false; for(var i=0;i<document.forms[0].elements.length;i++) { if(document.forms[0].elements[i].name=="dOption") { if(document.forms[0].elements[i].value=="N") { if(document.forms[0].elements[i].checked==true){ document.forms[0].PIN.disabled=false; document.forms[0].SSNfirst.disabled=true; document.forms[0].DOB1.disabled=true; document.forms[0].DOBRange1.disabled=true; document.forms[0].DOB2.disabled=true; document.forms[0].DOBRange2.disabled=true; document.forms[0].LastName.disabled=true; document.forms[0].FirstName.disabled=true; document.forms[0].MiddleName.disabled=true; document.forms[0].Last4.disabled=true; document.forms[0].First4.disabled=true; document.forms[0].Option1.disabled=false; document.forms[0].Option2.disabled=true; document.forms[0].Option3.disabled=true; } } else if(document.forms[0].elements[i].value=="T") { if(document.forms[0].elements[i].checked==true){ document.forms[0].PIN.disabled=true; document.forms[0].SSNfirst.disabled=false; document.forms[0].Last4.disabled=false; document.forms[0].DOB1.disabled=false; document.forms[0].DOBRange1.disabled=false; document.forms[0].DOB2.disabled=true; document.forms[0].DOBRange2.disabled=true; document.forms[0].LastName.disabled=true; document.forms[0].FirstName.disabled=true; document.forms[0].MiddleName.disabled=true; document.forms[0].First4.disabled=true; document.forms[0].Option1.disabled=true; document.forms[0].Option2.disabled=false; document.forms[0].Option3.disabled=true; } } else if(document.forms[0].elements[i].value=="R") { if(document.forms[0].elements[i].checked==true){ document.forms[0].PIN.disabled=true; document.forms[0].SSNfirst.disabled=true; document.forms[0].Last4.disabled=true; document.forms[0].DOB1.disabled=true; document.forms[0].DOBRange1.disabled=true; document.forms[0].DOB2.disabled=false; document.forms[0].DOBRange2.disabled=false; document.forms[0].LastName.disabled=false; document.forms[0].FirstName.disabled=false; document.forms[0].MiddleName.disabled=false; document.forms[0].First4.disabled=false; document.forms[0].Option1.disabled=true; document.forms[0].Option2.disabled=true; document.forms[0].Option3.disabled=false; } } } } } This works fine but the problem is we have 3 submit buttons with differnt actions using the normal <s:submit> works fine but when I use <s:submit action="Search1"> the javascript does not render. Here is an example of my jsp code: Code: <s:form id="Search" name="units" action="Search1"> .... ... <Table> <tr><td> <input name="dOption" value="T" onClick="chMd()" type="radio"> Option 2 <br /></td></tr> <tr> <td> <s:textfield name="crssn" label="SSN:" size="9" maxlength="9" disabled="true" value="xxxxxxxxx" onclick="clearText(this);"onblur="clearText(this);" required="true"/></td> <td><br><s:checkbox name="last4" label="Last 4" labelposition="bottom" disabled="true"/></td></tr> <tr><td><s:textfield label="DOB:" name="crdob1" size="10" maxlength="10" disabled="true" value="mm/dd/yyyy" onclick="clearText(this);"onblur="clearText(this);" /></td> <td><s:textfield name="crrange1" label="+/- months" size="1" disabled="true" /></td><td> </td><td> </td> <td> <s:submit action="Search2" name="Option2" value="Search"/></td></tr> </Table> Similarly for the other options. This does not seem to work. However if I use the same code without specifying an action it works. e.g. Code: <Table> <tr><td> <input name="dOption" value="T" onClick="chMd()" type="radio"> Option 2 <br /></td></tr> <tr> <td> <s:textfield name="crssn" label="SSN:" size="9" maxlength="9" disabled="true" value="xxxxxxxxx" onclick="clearText(this);"onblur="clearText(this);" required="true"/></td> <td><br><s:checkbox name="last4" label="Last 4" labelposition="bottom" disabled="true"/></td></tr> <tr><td><s:textfield label="DOB:" name="crdob1" size="10" maxlength="10" disabled="true" value="mm/dd/yyyy" onclick="clearText(this);"onblur="clearText(this);" /></td> <td><s:textfield name="crrange1" label="+/- months" size="1" disabled="true" /></td><td> </td><td> </td> <td> <s:submit name="Option2" value="Search"/></td></tr> </Table> Code: <Table> <tr><td> <input name="dOption" value="T" onClick="chMd()" type="radio"> Option 2 <br /></td></tr> <tr> <td> <s:textfield name="crssn" label="SSN:" size="9" maxlength="9" disabled="true" value="xxxxxxxxx" onclick="clearText(this);"onblur="clearText(this);" required="true"/></td> <td><br><s:checkbox name="last4" label="Last 4" labelposition="bottom" disabled="true"/></td></tr> <tr><td><s:textfield label="DOB:" name="crdob1" size="10" maxlength="10" disabled="true" value="mm/dd/yyyy" onclick="clearText(this);"onblur="clearText(this);" /></td> <td><s:textfield name="crrange1" label="+/- months" size="1" disabled="true" /></td><td> </td><td> </td> <td> <s:submit action="Search2" name="Option2" value="Search"/></td></tr> </Table> Any idea what I need to change in my javascript or jsp to get this to work? Hello, I have two frames, one to the left, one to the right. The left one contains a form, which I'm using to take in user input, and at the same time to refresh the frame on the right. The left frame's code is: Code: <html> <head> <script type="text/javascript"> function reload_right_frame() { parent.right_frame.location.reload(); } </script> </head> <form method="post"> <input type="submit" value="Enter" onClick="reload_right_frame();"> <input type='text' name='userinput'> </form> <?php echo "You entered: " . $_POST['userinput']; ?> </html> This succeeds in spewing out what the user entered, and simultaneously refreshing the right-hand frame. However, I want there to be a delay in refreshing the right-hand frame, so I changed the left-frame coding as follows: Code: <html> <head> <script type="text/javascript"> function delayed_reload() { var t=setTimeout("reloadframe()",3000); } function reload_right_frame() { parent.right_frame.location.reload(); } </script> </head> <form method="post"> <input type="submit" value="Enter" onClick="delayed_reload();"> <input type='text' name='userinput'> </form> <?php echo "You entered: " . $_POST['userinput']; ?> </html> This is where it stops working. The right-hand frame is not reloaded at all. I want it to reload after 3 seconds. The user input text is spewed out, though. If I change the input type from "submit" to "button", however, the delayed reload of the right-hand frame works fine, but then the user input text fails to show. How can I make both form and delayed reload both work? I'm probably missing something obvious. Thanks in advance for any help! The code below is a download form,, the number after the P= are the index idents for each file to be downloaded.. The destination_folder is set for C:\temp as default location. the code below works as needed for one file,,however i need to create a drop down list which will show all file names,and automatically throw the right ident for that file after the P=. sounds simple enough but there are other sections that are tied to this form so the solution has to use the CFForm_1(this) else i'll have to redo all the other sections as well. as well as javascript if anyone has a quick and clean way to do this i'd be very appreciative. i've pulled my hair out trying to find examples using this config and none are even close..or don't have a drop down menu Code: <form name="CFForm_1" action="http://www.XXX.cfm?p=6D6F615CC&rt=2&st=2" method="POST" onsubmit="CFForm_1(this)"> <input name="destination_folder" id="destination_folder" type="text" value="C:\Temp" maxlength="200" size="60" /> <input type="Submit" value="Resume"> thanks in advance, Rick Hello Everybody, I have a scenario where in i have 2 divisions, TOP and BOTTOM. In the BOTTOM Division i have a list box and Submit button in a form. User can select an item from the list box and click on the submit button. After user clicks the submit button i want to display some data/graph in the bottom division. However with my current code i see that on clicking the submit button , the data is displayed on a fresh page. Please guide me if this is possible or should i use a different logic. The code goes here. Code: <html> <head> <TITLE> Display Graph </TITLE> <script type="text/javascript"> function processData(form) { var BoardNumber = document.forms[0].elements[0].value; var BoardIndex = document.forms[0].elements[0].selectedIndex; alert("Selected board is :" + BoardNumber + ":Selected Index is :" + BoardIndex); document.write("Trying to print some data : "); document.write("<br>"); document.write("The board number is " + BoardNumber); } </script> <style type="text/css"> body { background-color : #fefefe; font-family:arial , verdana, sans-serif; text-align : center; } .page { margin-bottom : 10px ; text-align : left; font-size: 12px; background-color : 00ff00; background-repeat:repeat-y; border:1px solid #666666; height : auto; } .Down { margin-top : 10px ; text-align : left; font-size: 12px; background-color : ff0000; background-repeat:repeat-y; border:1px solid #666666; height : auto; } .header{ padding : 3px; background-color:#f3f3f3; } .content {padding : 10px; margin-left : 100px; } </style> </haed> <body> <div class = "page"> <div class = "header"><h1> My Company Name </h1> </div> <div class = "content"> <!-- The main Page Goes here --> <h2> Top DIVISION </h2> <p> This is test page. This is test page. This is test page. This is test page. This is test page. This is test page. This is test page. This is test page. This is test page. This is test page. This is test page. This is test page. This is test page. This is test page. </p> </div> </div> <div class = "Down" name="Down"> <h2> BOTTOM DIVISION </h2> <p> Down : I NEED TO DISPLAY DATA/GRAPH in the same division. Not in a fresh page???? <BR> <B> SELECT THE BOARD NUMBER and PRESS THE BUTTON "Process Request" </B> <form name = "SelectColor"> <select name = "boardnum"> <option selected = "selected " value = " " > select board </option> <option value = "Board_7125">7125</option> <option value = "Board_7325">7325</option> <option value = "Board_7335">7335</option> <option value = "Board_7340">7340</option> <option value = "Board_7342">7342</option> <option value = "Board_7400">7400</option> <option value = "Board_7401">7401</option> <option value = "Board_7405">7405</option> <option value = "Board_7420">7420</option> <option value = "Board_7550">7550</option> </select> <input type="button" name="process" id="process" value="Process Request..." onclick="processData(this.form)" /></p> </form> </p> </div> </body> </html> Hi every one Following is the situation I want a solution for, -I have a form whose contents are forwarded to a mailer program hosted on a server which sends out emails. So basically the form data is submitted to one Mailer page (I have no control over the mailer program). -After the form has been submitted the mailer program redirects to a default page or the "return " page specified by me..again redirects no matter what I have no control over it... -Now instead of being redirected to a page I want the form contents to be submitted to another php page which will appear after the form has been submitted to the mailer page and display the contents of the form originally submitted. Basically I want to submit to 2 different pages I know thats possible but I do not know how to get around the redirection from mailer page. I thought of having the second php page to be the redirect page with all form data sent in query string however data fields are too many to send over get. Is there anyway around this in javascript? Its very complex to explain..I hope some one can help I hope following crude visualisation helps currently submit form to------------->Mailer page (It redirects to any page specified) form to | | |------->Page2.php (Want this to appear after form has been submitted to mailer page but mailer page redirects..) Regards, Aditya Hi, I have a form that when you click submit gives a warning box asking if to continue code below Now when I type in the text field and press enter it doesn't submit nor does it pop up the warning box, how would I do this Code for submit button Code: <script LANGUAGE="JavaScript"> <!-- function submitMyForm() { var agree=confirm("ARE YOU SURE ?"); if (agree) return true ; else return false ; } // --> </script> Code: <form action="admin-delete.php" method="post" name="cp_delete" id="cp_delete"> <input type="text" name="cp_delete_bg" id="cp_delete_bg"> <input type="submit" name="submit" value="submit" onclick="return submitMyForm()"/> </form> Hi all Is using the real form submit button a problem in any way? Can it actaully send a form when a person uses 'enter' in a text field. When I use this submit, it triggers my validation which is great. Code: <input type="submit" value="OnSubmit validate" /> However this way doesn't seem to trigger my validation although It may solve the above form send problem (if that realy exists). How do I get it to act the same as real submit so it will trigger validation like onsubmit above? Code: <input type="button" value="Send Feedback" onclick="this.form.submit()" /> LT does any of that make sense? all ideas helpful and appreciated I've got the following 2 fields in my form: <input type="file" name="filename" id="filename" value="filename"> <input type="submit" name="submit" value="Upload Image" /> Now I want to hide both of them as soon as the submit button is pressed. Problem is that I'm a javascript noob and I can't find it with google :S Can someone help me? I have created some online software which uses form data to submit to another page. The problem is that I have other submit buttons in the same form which submit to different pages (depending on which button is pressed). The first submit button works fine but all the others only work once. Code: <input class="cssbutton" type='submit' value='Button1' onclick="wbform.action='page1.php'; target='mainFrame'; return true;"> <input class="cssbutton" type='submit' value='Button2' onclick="wbform.action='page2.php'; target='_blank'; return true;"> <input class="cssbutton" type='submit' value='Button3' onclick="wbform.action='page3.php'; target='topFrame'; return true;"> <input class="cssbutton" type='submit' value='Button4' onclick="wbform.action='page4.php'; target='topFrame'; return true;"> <input class="cssbutton" type='submit' value='Button5' onclick="wbform.action='page5.php'; target='_blank'; return true;"> <input class="cssbutton" type='submit' value='Button6' onclick="wbform.action='page6.php'; target='_blank'; return true;"> Any ideas my friends? I am trying to auto submit a login form remotely using .submit() . It's submitting, but for some reason if I use submit() the login isn't processing. However, if I turn off the auto submit and use an actual submit button it logs in just fine. Now, in the form tag there is a call onsubmit for some validation, does .submit() trigger that form onsubmit="" function? Is there something that happens differently when a user clicks a button verses the .submit(). Thanks! Paul 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 Hi, I want submit a form when highlight options select value = true. I did the following code, but it not works. Could someone help me to fix it? Quote: <script type="text/javascript" language="JavaScript"> if onfocus="url.select()" Return true; { document.form1.submit(); } </script> stickers I have a basic understanding of Javascript, and I have posted here before. And my question is rather simple. I work for a company that moderates a virtual world. We have a mod tool but its kind of goofy. We have to edit a URL and then send the URL in a browser. It's a long and boring process. I am looking to have a basic form that puts all the required information together and submits it. What I can't figure out is how to submit a URL in javascript but not load it in a new window. This is a sample of what I currently use in another javascript used by the company: Code: theReport = replace(theReport,'\n','<br>'); var disp_setting="toolbar=no,location=no,directories=yes,menubar=yes,scrollbars=yes,width=480, height=640, left=400, top=0"; var docprint=window.open("","",disp_setting); docprint.document.open(); docprint.document.write('<html><head><title>Report Generator</title>'); docprint.document.write('</head><body>'); docprint.document.write(theReport); docprint.document.write('</body></html>'); docprint.document.close(); docprint.focus(); Hi all, Im pretty new to HTML and Javascript so please bear with me if Im not explaining my problem well! I am building a website at work which has 2 frames, a main frame and a smaller frame at the side. In the smaller frame I have a text box and search button which will locate and open documents thats name match the text input. Everything seems to be working fine, however I have 3 problems.... 1) How do I complete the search by clicking enter instead of clicking the search button? 2) How do I get the text box to reset/clear after I have submitted a search? At present the entered text remains after I have completed the search 3) Can I get the text box to be selected and be ready for text input when I click on the frame that contains this? As it stands I have to click on the text box itself before I can enter text! Sorry for all the questions! As I said im pretty new to this and learning as I go along, so if you can point me in the right direction it will be greatly appreciated! Thanks Glen I have a userscript that helps me move things around on a vB based forum that I moderate. I am using the following to quickly select and submit my selection, however, when it hits the document.vbform.submit(); part of the code the pages just sits there. It does work if the forum ID's I have in place don't line up with any of the forum ID's on the forums but it just will ooad the page and say no such forum exists. So I know submit(); can work..... Code: // INJECT FUNCTION TO PAGE FOR LATER USE window.InjectFunction = function(reg) { if (reg == "na") { var theScr = "" + "function des(id) {" + "\nvar destination = document.getElementsByName('destforumid')[0];" + "\nvar radio = document.getElementsByName('redirect');" + "\nif (id == '39') {" + "\nradio[0].checked = true;" + "\n}" + "\nelse {" + "\nradio[2].checked = true;" + "\n}" + "\nfor ( var i = 0; i < destination.options.length; i++ ) {" + "\nif ( destination.options[i].value == id ) {" + "\ndestination.options[i].selected = true;" + "\nreturn;" + "\n}" + "\n}" + "\ndocument.vbform.submit();" + "\n}" } var scrTag = document.createElement("script") var scrHead = document.getElementsByTagName("head")[0]; scrTag.setAttribute('type', 'text/javascript'); scrTag.appendChild(document.createTextNode(theScr)); scrHead.appendChild(scrTag); } // ADD MENU THAT WILL PASS FORUM IDs AND CALL INJECTED FORUMS window.NewMenu = function(reg) { var divTag = document.createElement("div"); divTag.id = "div1"; divTag.setAttribute("align","left"); divTag.style.margin = "0px auto"; divTag.style.backgroundColor = "#f5edc3"; divTag.style.position = "fixed"; divTag.style.bottom = "0px"; divTag.style.left = "50%"; divTag.style.width = "196px"; divTag.style.marginLeft = "-98px"; divTag.style.height = "auto"; divTag.className ="dynamicDiv"; divTag.zIndex = "1000"; document.body.appendChild(divTag); if (reg == "na") { var dBody = '<div class="newmenu" onClick="des(\'2\');">SELECTION 2 </div>' + '\n<div class="newmenu2" onClick="des(\'43\');">SELECTION 2 </div>' + '\n<div class="newmenu" onClick="des(\'41\');">SELECTION 3 </div>' + '\n<div class="newmenu2" onClick="des(\'15\');">SELECTION 4 </div>' + '\n<div class="newmenu" onClick="des(\'4\');">SELECTION 5 </div>' + '\n<div class="newmenu2" onClick="des(\'3\');">SELECTION 6 </div>' + '\n<div class="newmenu" onClick="des(\'19\');">SELECTION 7 </div>' + '\n<div class="newmenu2" onClick="des(\'39\');">TRASH </div>' ; } divTag.innerHTML = dBody; } var location = window.location.toString(); var region = location.substring((location.indexOf("//") + 2), location.indexOf(".")); var view = location.substring((location.indexOf("board/") + 6), location.indexOf(".php")); if (view == "forumdisplay") { HideMoveClose(); ColorThreads(); } else if (view == "postings") { var destination = document.getElementsByName('destforumid')[0]; if ( destination != null) { ChangeRedirect(); InjectFunction(region); NewMenu(region); ApplyCSS(); window.scrollTo(0,document.body.scrollHeight); } } else if (view == "search") { ColorThreads(); } else { //alert(); } Please note I have edited out a large portion of this code to make the search for the problem a little easier and the code that remains is relevant to the issue. As you can see there are other functions and blah blah but those all work correctly. On the if statements I removed the else if's and else since they are basically just the same thing as the if portion just with a different region code. I have wrapped this whole deal in try {} catch() {} but no errors get thrown. Please any thoughts? OK! I re adjusted some things after some research. Still a bit confused: Code: <!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> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>login</title> <script type="text/javascript"> function encode64(form) { var username=un; var password=pass; var ip=ip; var enKey= 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; var deKey = new Array( -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1 ); var str=new Array(); var ch1, ch2, ch3; var pos=0; while(pos+3<=src.length){ ch1=src.charCodeAt(pos++); ch2=src.charCodeAt(pos++); ch3=src.charCodeAt(pos++); str.push(this.enKey.charAt(ch1>>2), this.enKey.charAt(((ch1<<4)+(ch2>>4))&0x3f)); str.push(this.enKey.charAt(((ch2<<2)+(ch3>>6))&0x3f), this.enKey.charAt(ch3&0x3f)); } if(pos<src.length){ ch1=src.charCodeAt(pos++); str.push(this.enKey.charAt(ch1>>2)); if(pos<src.length){ ch2=src.charCodeAt(pos); str.push(this.enKey.charAt(((ch1<<4)+(ch2>>4))&0x3f)); str.push(this.enKey.charAt(ch2<<2&0x3f), '='); }else{ str.push(this.enKey.charAt(ch1<<4&0x3f), '=='); } } return str.join(''); } var encusername = encode64 (un); var encpass = encode64 (pass); //script andy gave me function checkUrlRandom(url){ var mathRnd = Math.round(Math.random()*10000); if(url.indexOf("?") > 0 ){ url = url + "&rnd=" + mathRnd; }else{ url = url + "?rnd=" + mathRnd; } return url; } //HOW DO I GET THE ENCODED USERNAME AND PASSWORD AND NON ENCODED IP ADDRESS TO POST INTO THE URL UNDENEATH THIS AND THEN GO TO THAT URL? xhr = new XMLHttpRequest(); xhr.open("GET",checkUrlRandom("http://"+ip+"/User.cgi?cmd=get_login&username="+encuseranme+"&password="+encpass+"")); </script> </head> <body> <form name="form" method="get" onclick="encode64(this.form)"> <p> <label for="ip">ip</label> <input type="text" name="ip" id="ip" /> </p> <p> <label for="username">username</label> <input type="text" name="username" id="username" /> </p> <p> <label for="password">password</label> <input type="text" name="password" id="password" /> </p> <p> <input type="submit" name="submit" id="submit" value="click" /> </p> </form> </body> </html> HOW DO I GET THE ENCODED USERNAME AND PASSWORD AND NON ENCODED IP ADDRESS TO POST INTO THE URL AND THEN GO TO THAT URL? thanks -Mike Hello. I have created a form via innerhtml, like this: content.innerhtml = "<form action =\"customer.php\" method=\"post\">"; content.innerhtml = "<input type = \"text\" name = \"Username\" />"; content.innerhtml = "<input type = \"submit\" value = \"Submit\" />"; When I click submit, instead of running the php file, nothing happens. I tested it outside the script and it works just fine. Is there any other way I can make this work inside the script? Thank you. |