JavaScript - Auto Fill Text Box When Text Entered Into Another Text Box
Hi,
I have a form with 9 text fields and a text area. What I want to do is replace the text in the text area depending on how many fields contain text. For example my text boxes are named 1 to 9, if the user enters text in the first five boxes I want the text area to auto fill with 'you have selected boxes 1 to 5' if the user selects all nine it will say 'you have selected 1 to 9', therefore, the user must complete the text boxes in order. I have it working with an onchange event but i have a button on the form to also auto fill the text boxes and it does not work if this is clicked. Any help would be appreciated! Similar TutorialsAs of right now I have a code that will work in IE but wont work in FireFox...go figure. Basically what I want to have happen is when you type in an area code it will provide an output in a predetermined area of the page. For Example: Input- 512 Output - Austin, TX The code that I have doesn't work with firefox and I was just wondering if there was a code that would allow that to happen. Thanks! Hello! I need some help here. I need to pre-populate a name and a phone number box based on what's entered in the employee id box. By entering in the employee id - EMPLOYEE ID: [JOHN R] It automatically fills in - Employee Name: [John Roberts] Employee Phone: [1234567890] Thanks. Hi, I'm hoping this will be an easy one for you experts out there. I am working on a convention registration form. What I'm trying to do is have the text "50.00" pop into the COST field when any text (even if it's only one character) is entered into the NAME field. If the text in the NAME field is deleted, the "50.00" should also be deleted. Does anyone have a script that does this? Thanks! Hello now i found better way how to show it to you people. I finished one teail of this workd . Now the most important thing i need to do is > 1. Check this http://zr-gaming.ucoz.com/index/ban_lista/0-5 2. In place "Nick Igraca" __________ . When i type there something , that text shoudl go automaticly in table oben Example When i write "OMG" it should fill "OMG" Under "Nick Igraca" There you see Pred@t0R is allredy filled in , but i do it alone in codes . So i want when i fill the text and press submit it should go to real place automaticly , so it should be filled in . How can i do it ? I hear i need some script or something . I will give you Reward and Reputation points for help , its inportant for me , i need to finish it for 24 hours . Thank you very much guys . If you dont understand something just tell me . And very thanks to you who will try to help me . Hi all, Thanks for reading. I'm having an issue trying to accomplish the following - I have a text field (field1) already displayed on the HTML page. However, there's a link where you can add additional text fields to the page as well. When the link is clicked, the second text field is added successfully (field2), and when the link is clicked again, the third text field (field3) is added successfully. However, the third field does not add itself to the page, and the text for anything greater than a third field also isn't displayed after. This obviously means that my "fields" variable is not working right, so I'm wondering, would anyone be able to assist me to help me get that variable processing correctly? Code: <script language="javascript"> fields = 1; function addMore() { if (fields = 1) { document.getElementById('addedMore').innerHTML = "<input type='text' name='field2' size='25' /> <span>Field 2.</span>"; fields = 2; } else if (fields = 2) { document.getElementById('addedMore').innerHTML = "<input type='text' name='field3' size='25' /> <span>Field 3.</span>"; fields = 3; } else { document.getElementById('addedMore').innerHTML = "Only 3 fields are allowed."; document.form.add.disabled=true; } } </script> Here is the code in my HTML - Code: <input type="text" name="field1" size="25" /> <span>Field 1.</span> <div id="addedMore"></div> <p class="addMore"><form name="add"><a onclick="addMore()">Add another field.</a></form></p> Thank you very much. I am not a programmer, so there is a problem need help. Below, how this can be achieved it(here)? thanks in advance!! Code: <ul id="nav"> <li><a href="#1">his is a long piece of text which will need to be truncated.</a></li> <li><a href="#2">This is a long piece of text which will need to be truncated.</a> <ul><li><a href="#">This is a long piece of text which will need to be truncated.</a></li> <li><a href="#">This is a long piece of text which will need to be truncated.</a> <ul><li><a href="#">This is a long piece of text which will need to be truncated.</a></li> <li><a href="#">This is a long piece of text which will need to be truncated.</a> <ul><li><a href="#">This is a long piece of text which will need to be truncated.</a></li> <li><a href="#">This is a long piece of text which will need to be truncated.</a> <ul><li><a href="#">This is a long piece of text which will need to be truncated.</a></li> <li><a href="#">This is a long piece of text which will need to be truncated.</a></li> </ul> </li> </ul> </li> </ul> </li> </ul> </li> <li><a href="#3">This is a long piece of text which will need to be truncated.</a></li> <li><a href="#4">This is a long piece of text which will need to be truncated.</a></li> <li><a href="#5">This is a long piece of text which will need to be truncated.</a></li> </ul> Does anyone know how to go about getting a function a bit like fckeditor / ckeditor where when you type a full URL into the 'link to' box it automatically removes the 'http://' part on the fly (i.e. as soon as another character after the initial 'http://' is typed), just leaving the user with www.etc.... in the input? I am trying to build something similar, and am a bit lost going through the fckeditor code! Thanks, Neil Hello. I have a textarea where user can select a text then copy to clipboard (using EditArea script for highlighting) I need append additional information to the selected text so it won't be visible in the textarea, but only appear after copied to clipboard. For example: Code: text line one text line two text line three user selected word "two", hit CTRL+C to copy into clipboard (or used browser's context menu), but in clipboard it should be saved as: "selected word 'two'" What would be the approach? Thank you. Hi, I have a form setup so that selecting a radio button opens a specific text field. The problem is if the user starts to enter information, then switches to a different radio button (perhaps they chose the wrong radio to start), the text they already started to enter on the previous textfield doesn't get cleared. This will be a problem later when inserting to sql. Here is a summary of the code: Code: <head> <script type="text/javascript"> function doClick(objRad){ if (objRad.value=="0"){ document.getElementById("textbox").style.display='block'; } else{ document.getElementById("textbox").style.display='none'; } if (objRad.value=="1"){ document.getElementById("textbox1").style.display='block'; } else{ document.getElementById("textbox1").style.display='none'; } if (objRad.value=="2"){ document.getElementById("textbox2").style.display='block'; } else{ document.getElementById("textbox2").style.display='none'; } } </script> </head> <body> <form action="insert.php" method="post"> <p>Please choose the business type: <input type="radio" name="rad" value="0" onclick="doClick(this)"> Sole Proprietorship <input type="radio" name="rad" value="1" onclick="doClick(this)"> Partnership <input type="radio" name="rad" value="2" onclick="doClick(this)"> Corporation <div id="textbox" style="display:none"> <input type="text" name="txt"> This is my sole proprietorship info.</div> <div id="textbox1" style="display:none"> <input type="text" name="txt"> This is my partnership info.</div> <div id="textbox2" style="display:none"> <input type="text" name="txt">This is my corporation info. </div> </form> </body> Any help is appreciated, Thanks in advance! Hi. I have developed a form all working fine but am struggling on the following. I need a checkbox for an item, when the checkbox is true the user can enter text in a text box, only if the checkbox is ticked. I have numerous items I need for this. Hope someone can help. Thanks im clueless when it comes to javascript, but this is what im trying to find: i have a page that has multiple text areas, i also have 4 links that when clicked i want to add some predefined text into the active text area the one with the text cursor in? The Hyperlinks: Code: <a href="#sc">Shift Changed</a> | <a href="#ol">On Leave</a> | <a href="#ot">OverTime</a> | <a href="#ss">ShiftSwap</a> The textareas: PHP Code: <td><textarea name=details$i rows=4 align=absmiddle cols=16 value="$details[$i]\">$details[$i]</textarea></td> as you can see the textareas are created on the fly based on a php array. would anyone be willing to put some code together for this? or even give me the basics on how i can get the active textarea's name so i can pass that to a script that inserts into a given field? Hello there, this is my first post on this forum. I have learned a good bit of PHP and have implemented it for use in my work as a math tutor. My kids are telling me, however, that it is too inconvenient to hit tab or click on the next text box and would prefer to use the old style pencil and paper. I thought of a good idea: Javascript would be able to automatically focus the curser on the next text box if some condition was met. For example: 6+7. If the textbox reads 13, it will focus on the next text box. Otherwise, nothing happens. This kills three birds with one stone; the user will know if they got the question right or wrong and it will move automatically if they got it correct. The problem is I lack any real JavaScript wisdom. I would guess this would be quite simple. The closest thing I have found upon searching was this from the user requestcode, but this has to do with once the user has typed in 4 characters it moves automatically. Code: <SCRIPT LANGUAGE="JavaScript"> function nextbox(fldobj,nbox) { if(fldobj.value.length>3) {document.forms[0].elements[nbox].focus()} } </SCRIPT> </head> <body onLoad="document.myform.txt1.focus()"> <CENTER> <FORM NAME="myform"> <INPUT TYPE="text" NAME="txt1" SIZE="4" MAXLENGTH="4" onKeyUp="nextbox(this,1)"> Thank you for the help. Hi, Here's a sample form: Code: <form action="#" method="post"> Name:<br /> <input type="text" name="name" value="your name" /><br /> E-mail:<br /> <input type="text" name="mail" value="your email" /><br /> <input type="submit" value="Send"> </form> When you tab to a text input, the value gets highlighted. How can it be disabled? Any help is appreciated! Mike I know only basic Javascript. I'm making a choose-your-own-adventure game, but want parts of each "page" to display conditionally. For example: You see a sword, a hat, and a helmet here. Take sword Wear hat Wear helmet Continue into swamp Clicking "Take sword" would set a variable "haveSword" to true, and the page would display: You heft the sword, testing its razor edge against your thumb. You see a hat and a helmet here. Wear hat Wear helmet Continue into swamp It tells you the results of your action, then repeats the main part, but updated to reflect any changes. If you then pick "Wear helmet," it shows the action and main paragraph, but updated to reflect that change, etc., all in any order that you choose. This is a simple example, but I would like a system that allows for more complex interactions, that you can perform all in the same "room." Later on in the adventure, when you enter the dragon's lair, you get a page detailing the encounter: if you have the sword, you can attack the dragon, or else you get a paragraph about being powerless. The dragon attacks you, and if you have the helmet, it protects you; if you only have the hat, you get a sentence about it going up in flames before you die; and if you have neither, you just die. The concept is pretty simple, but I don't know how to code it cleanly in Javascript. I currently have each "page" contained in a hidden <div> tag with its own id. I put them in the body instead of as vars in the script because fiction has lots of single and double quotes which need escaped and make it hard to type and read (e.g., \"How\'re you doin\'?\" he asked.). I'd like to keep it that way, but maybe that's unrealistic. I have two placeholder divs in the body. OnLoad puts the first "page" of the adventure into placeholder2 using innerHTML. Clicking on a link in the text, like "Take sword," puts "You heft the sword..." into placeholder1 and refreshes the text of placeholder2. But I need that text to stop displaying the "Take sword" option if "haveSword" is now true, and not mention the sword in the room description... A different story that shows what I'm looking for, but is unfinished and unsustainably messy, can be found at http://taleofwayfinder.webs.com/red_0_2.html tl;dr How can I insert a paragraph using innerHTML (or whatever method) and have it evaluate what parts/options to display when it inserts? Hi again For instance I want to display some announcements from an external text file on a predefined box, like lets say 140 wide and height scalable according to text. The texts would be some announcements from me, a few words. I want the text justified and with previous / next link, if possible. And when they navigate to another page, they will get a random message in that box. There are news tickers on the net, but I just want something simple like this, no scrolling, fading, etc.. Has anyone a clue how I can accomplish that? Thanks. Hello everyone. I was wondering if anyone could help me come up with a script for fading text in and out then changing the text to something different when it fades back in again. I want to overlay a series of quotes on my website across the top and have them display for about 15 seconds then fade out to a new quote and have it cycle through them all indefinitely. I am pretty new to javascript and not much more experienced in html in general, so please be as thorough as possible. I'm a true noob Thanks!
I have a form with two text input boxes. I want to limit the text typed into the boxes as follows: 1. Either box can have the number 2 typed in, but the other box must remain empty OR 2. Each box can have the number 1 typed into Is this possible with JS and, if so, how do I do it?? hey im new to javascript and im working in this function , i can't get it work here is my code PHP Code: <SCRIPT LANGUAGE="JavaScript"> function text(form1) { var j = document.form1.diary.value; j = j.italics(); document.form1.diary.value = j ; } </SCRIPT> whats the problem ? I need to replace the captions with simple text for download speed purposes. This is controlled by a piece of Javascript written for me. I need to change the caption image for a text one. The site is here Frank alias effpeetee. Hi, I am wanting to insert text into a text area when a button or link is clicked. I know how to replace the whole lot in the text area, but I want it to insert text where the flashing cursor is in the text box. (Like Wikipedia) If any one can help, Then I will be very, very greatfull. Thank You. |