JavaScript - Hiding File And Submit Field After Submit
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? Similar TutorialsAlright, working on an ajax image uploader, and im a bit rusty with JS. How would i go about hiding the form after the submit button is pressed, so it disappears? Heres my website. If you need the scripts, just ask. Thanks in advance. How can I hide/disable the submit button if the name Todd is selected? Code: <html> <head> </head> <body> <form name="people"> <select name="group"> <option value="Pick Your Name">Choose</option> <option value="Tom">Tom</option> <option value="Freddy">Freddy</option> <option value="Todd">Todd</option> <option value="Fred">Fred</option> <option value="William">William</option> <option value="Johnson">Johnson</option> </select> <INPUT TYPE=submit VALUE="submit"> </form> </body> </html> 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> Hello Having problems with the following...a client needs me to replicate this contact page: http://www.ravenrow.org/contact/ In particular he wants the subscribe/unsubscribe to appear only when one enters text into the text field (as it does here). I have recently changed from using tables to div tags but this was the first website where I started to experiment with divs. Unfortunately therefore it is a mixture of tables and divs. But here is my page: http://www.rowingpresents.com/contact.html Can someone tell me what I need in my code to have to subscribe/unsubscribe appear and disappear as it does at ravenrow.org. Many thanks S This is probable very easy, I've tried with normal html and am unable to get my head around it. I would like to in some way replicate how a web browser works. I have a form entry field with a submit button at the top of the page. Under that I have an iframe. I copy the url http://www.bbc.co.uk into the entry field, click submit and the iframe updates with the website. Have looked around and haven't found anything similar. Code so far.... <form target="myURL"> <input type="text" name="goTo"> <input type="submit" name="submit" value="submit"> </form> <iframe src="" name="myURL" border="0" frameborder="0" width="768" height="354"></iframe> Thanks in advanced. Death = $Mill I thought this would have been fairly simple but it appears the onchange event isn't triggered when a hidden field is populated by other javascript without user input. I have a simple search box and autocomplete/suggestion ajax thingie going on. What I want to do is have my "Go" submit button disbled until AFTER a user has populated the hidden field "cid". A user populates this field automatically when they click on a suggested option from the ajax autocomplete doofer. Here's what I've tried at the moment but failed on. Code: <form action="index.php" method="GET" name="qsform" id="qsform"> <input type="hidden" name="p" id="p" value="compdetails" style="border:1px solid #000000;" /> <input type="text" name="quicksearch" id="quicksearch" value="Find Company" style="border:1px solid #000000;" onFocus="clearText(this)" onBlur="clearText(this)" /> <input type="hidden" name="cid" id="cid" value="" style="border:1px solid #000000;" /> <input type="submit" name="go" id="go" value="Go" disabled="true" onmouseover="if (document.qsform.cid.value!='') { document.qsform.go.disabled=false; }" /> </form> 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? 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 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 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, 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(); 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 Hi! I have a page with 8 different <input type="select"> fields. All the time only one out from this 8 is shown. the rest of them are hidden with css: display:none; How can I submit with POST only the select that's showing, and not the rest? All of them have differnt names. Like dropdown1, dropdown2, and so on... I dont know how can I get the value out from the one that's shown, and not the rest. Please Help my brain is about to explode... Hi, Normally when i try to put a form in a html page i use the Code: <form action="http://www.site.com/test.php" method="post"> and so on with the respective input (Something i learn over here) Today i was trying to create a html box whith the purpose of submiting to a external site but the problem i got is that the external site doesn't use the Code: <form> tag to submit and uses javascript in an onclick event. Is there any way i can still submit? Note: I tried an iframe 0 to load up the site and the respective scripts and emulate the submition in the top page but didn't work out. Thanks for all the help... When you use a form and submit it the URL bar changes to what the submitted values are. So can anyone explain how to use this?
hi i have a form where i need to join fields from the form prior to submission to flow into a pdf form. here is the function PHP Code: <SCRIPT language='javascript' type='text/javascript'> function joinna(form, elemName, ttl) { form.bname.value = form.b_fname.value + ' ' + form.b_lname.value; } </script> here is what the form input looks like PHP Code: <input class="left" onBlur="mark(this,'#ffffff','#000000')" name="b_fname" size="20" maxlength="40" onFocus="nextfield ='cb_fname'; mark(this,'#FFFF99','#0000FF')" value="<?php echo $row['b_fname'];?>" onChange="joinna(this.form,'b_fname','p1f6');"> </span> <input class="left" onBlur="mark(this,'#ffffff','#000000')" name="b_lname" size="20" maxlength="40" onFocus="nextfield ='cb_fname'; mark(this,'#FFFF99','#0000FF')" value="<?php echo $row['b_lname'];?>" onChange="joinna(this.form,'b_lname','p1f6');"> </span> and here is the calc field PHP Code: <input type="hidden" NAME="bname" value="" Size="7" onBlur="mark(this,'#ffffff','#000000')" onFocus="blur();document.smartform.bname.focus()" onChange="this.form.b_fname.value + this.form.b_lname.value; joinna(this.form,'field');" > this works fine IF i manually insert something new into the b_fname field. but lets say a user pulls the for to edit, and then makes no changes, "bname" will remain blank. what i want to do is call the function and/or force an 'onchange' or do whatever so bname is not left blank in the event the user submits w/o making any changes to the form tia 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? 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 |