JavaScript - Add/edit/delete From Input To Text Area
Hi,
I am not sure if what I am trying to do can be done, but basically I want to add/edit/delete information in a text area from inputs. I know how to add from inputs to text area but I am struggling with the edit and delete. Code: <script language="javascript" type="text/javascript"> function addtext() { var newtext = document.AddProduct.extran.value + ":" + document.AddProduct.extrav.value + "|"; var newfields = document.AddProduct.extran.value + ":" + document.AddProduct.extrav.value + "|"; document.AddProduct.extraf.value += newtext; document.getElementById("fields") += newfields } function removetext() { var re = new regExp("(^|,)\\s?user3","gi"); document.getElementById('extraf').innerHTML = document.getElementById('extraf').innerHTML.replace(re,""); } </script> </head> <body> <form method="post" enctype="multipart/form-data" action="process-forms.php" name="AddProduct" class="admin_form"> <dl> <dt><label for="Addfield">Custom Field(s) :</label></dt> <dd>Name: <input size="10px" type="text" name="extran" id="extran" value=""> Value:<input size="10px" type="text" name="extrav" id="extrav" value=""></dd> </dl> <dl> <dt>blej</dt> <dd><textarea name="extraf"></textarea> <input type="button" value="Add New Text" onClick="addtext(AddProduct);"><br/> <input type="button" value="Remove Text" onClick="removetext();"> </dd> </dl> <div name="fields" id="fields">here</div> </form> Currently if you click add, it adds the 2 input fields in to the text area separated by : and then ended by | so I can determine new lines, the first input will be "name" the second will be the "value". What I would like to do is be able to edit and delete these from the text area if possible? Hope some one can point me in the right direction? Thanks Similar TutorialsHello all I'm working on a simple feedback form (well not so simple for me) for the last page of my site. In the text area I expect to get normal western text PLUS (or even just) Chinese xharacters my question is how do you validate Chinese character input? low tech Is there any way that I can have multiple textboxes where the user can enter text (such as "black or green") and it would edit a css file, like this: Code: <style> body{ background-color:INPUT; } </style> <input type="text" name="bg"/> ? As 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! I want to limit a textarea to 500 characters. So somebody can't type in more than 500 characters or paste anything with more then 500 characters in the text box. However, if somebody were to enter something into the fields favoritedrink OR to favortefood, then I want the limit to change to 100 characters for the textarea. How can I do that using Javascript? I am using the form code below as an example. Code: <form action=""> <input type="text" name="firstname"><br /> <input type="text" name="lastname"> <textarea rows="2" cols="20" name="description"></textarea> <input type="text" name="favoritefood"> <input type="text" name="favoritedrink"> </form> I need some help for my site and would so much appreciate if somebody can help me with my problem. Thanks so much for any help. Hi all. I have the form below... Code: <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <form action="thankyou.php" method="get"> <td width="16%"><b>Your Name</b></td> <td width="84%"<input type="name" size="50" name="name" id="name"</td> </tr> <tr> <td width="16%"><b>Your E-mail</b></td> <td width="84%"<input type="text" size="50" name="email" id="email"</td> </tr> <tr> <td width="16%"><b>Text Area</b><br>Limit 50,000 characters<br>X amount characters left</td> <td width="84%"><textarea name="summary" id="summary" cols="50" rows="10"></textarea></td> </tr> <tr> <td><b>Video URL</b></td> <td><input type="text" size="50" name="video" id="video"></td> </tr> <tr> <td><b>Upload Image</b></td> <td><input type="file" size="50" name="image" id="image"></td> </tr> <tr> <td><br><input type="submit"></form> </td> <td</td> </tr> </table> I would like to change it so... When somebody submits a Video URL, the Upload Image input box is disabled When somebody does an Upload Image, the Video URL field is disabled If somebody enters more than 1,000 characters in the Text Area, then both Video URL and Upload Image fields are disabled. When somebody enters a Video URL or does an Upload image, the Text Area is limited to 1,000 characters For the words "Limit 50,000 characters" to change to "Limit 1,000 characters" if somebody enters a Video URL or Upload Image Where it says X amount characters left, it should changing depending on the amount of characters a user has typed in. Can anybody please help me achieve this above using JavaScript? It would be infinitely appreciated. 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! 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? 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 ? 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. Hi all can someone guide me (total JS newbie) on this presumably pretty easy task? I have a "parent" page with some text inputs in it (a form). This is what I am after: -when the user clicks a link it pops open a new window via JS - "child" (this is working). -in the "child" window there are also some text inputs (another form) (done). -when the user changes the value for 'testChild_textInput_4' in the child window, then I want it to automatically set this same value, to effectively overwrite, what is currently in 'testParent_textInput_2' in the parent window. Presumably this involves an onChange event, but it is also OK with me if the needful (the text input's value in the parent window being overwritten) happens upon the child window's form submit. If anyone can show me either trick, I would be thrilled! I set up a test page to make this all easy to talk about: http://www.yellow-turtle.com/testDumpMe_parent.html Please let me know! Thanks! -John I am thinking this should be fairly easy but yet I am not getting far. I want to have a form with a single text imput field for a zip code. Depending on which zip code the user enters will determine which url they will be sent to. If they enter a zip code which is not in the script, they would be sent to a default url. I am also assuming this can be accomplished with javascript. Any help is greatly appreciated. So I'm working with a code that I can't seem to get the translation to show up in the text area. The user is supposed to enter text in a text area on the left hand side, hit the translation button, and the translation will appear like a sentence in the right hand text area. I don't seem to be able to get anything to show up in the right hand text area........ I know that i'ts probably something very simple that I am not seeing because at this point I am brain dead. Code: phrases = [["hello","ahoy"],["pardon me","aaarrgghh"],["excuse me","aarrr"], ["hows it going","hows it goin"],["sir","matey"],["madam","proud beauty"], ["woman","beauty"],["children","sprogs"],["where is","whar be"], ["can you help me find","know ye"], ["is that","be that"],["how far is it to?","how many leagues to"], ["the","th'"],["my","me"],["your","yer"],["there","thar"], ["outstanding","outstandin"],["attractive","attractive"],["happy","horny"], ["dead","went t' Davy Jones' locker"],["restroom","head"],["restaurant","galley"], ["hotel","fleabag inn"],["pub","pub"],["I would like to","I be needin' t"], ["I desire","I desire"],["I wish I knew how to","I'm a hankerin' t"], ["my mother told me to","MeAhoy! ol' mum, bless her black soul, always tol' me t"], ["have a great dinner","have a great what crawled out o' t' bung hole"], ["have a cocktail","swill a pint or two o' grog"],["fall on the ground","fall on t' ground"], ["get drunk","get splice t' mainbrace"]]; function Translate(text) { for(var i = 0; i < phrases.length; i++) { var toReplace = new RegExp("\\b"+ phrases[i][0]+"\\b", "i"); var index = text.search(toReplace); while(index != -1) { text = text.replace(toReplace, phrases[i][1]); index = text.search(toReplace); } } return text; } Code: <div> <textarea id="first_text" style="float:left" id="task_list" rows="20" cols="53"></textarea> <button id="translated" width="50px" heigth="100px" ><img src="pirate2.gif" />Translation----></button> <textarea id="second_text" style="float:right" id="task_list" rows="20" cols="53"></textarea> </div> HI to all I am new be and not able to resolve the issue when i tries to edit text area everything works fine for crome and ie but does not work for firefox in fire fox when i try to edit intially everythings works fine but if i click other feild in form and after that try to edit text area backspace key stuck up and does not work please help me ?? code which i am using is menitoned below function stopPropagation(e) { e = e||event; /* get IE event ( not passed ) */ e.stopPropagation? e.stopPropagation() : e.cancelBubble = true; } function checkShortcut(e) { stopPropagation(e); if({8:1,13:1}[e.keycode||e.which]) { if( x ) return true; return false; } } Hi, I have a text area that I want to add simple html formatting buttons to. The user should be able to: - highlight text and click a 'bold' button - highlight text and click 'itallic' button - Add bulleted list - Link I've looked at a number of WYSIWYG javascript examples, but they seem to accept Microsoft Word formatting, which I dont want. Need help with my text box. I want to make it so if i have several text boxes only one number can be entered once. So if i type the number 15 in the first text box and type 15 in the second text box an error will occur saying you cant enter the same number twice. Any idea how to do this? Code: <html> <head> <title>Untitled Document</title> <script> function checkForInvalid(obj) { obj.value = obj.value.replace(/[^0-9\-]|(-{2,})/gi, (RegExp.$1.indexOf("-") > -1) ? "-" : ""); } </script> </head> <body> <form name="myForm"> <input type="text" name="one" onkeyup="checkForInvalid(this)"> <br> <input type="text" name="two" onkeyup="checkForInvalid(this)"> <br> <input type="text" name="three" onkeyup="checkForInvalid(this)"> </form> </body> </html> Thanks I'll admit I'm new to javascript, so my apologies if this looks like crap. Code: Taken out due to fix I'm trying to get this javascript to return a level to this form field. Code: taken out, due to fix Hello im trying to update a text area value with edited code with javascript, i dont know how to and im asking if you guys know
Hi, i want to open a file in a text area, such that the user can either browse for a file and when selected it will open in a text box on the page, or the user can select a file from a list of active links on the page and this will open in the text area. I am new to java and dont know where to start on this, i have been browsing resources on the internet but have not found anything to get me started, would anybody be able to help? Thanks I have a need to display, edit and save the contents of a text area to a text file or what ever is best suited, directly to the website root or folder within the root of the site. Is there anyway this can be done with out database software? As I dont have the option to install mysql or any other software to the webserver. Any help would be greatly appreciated. Thx Just a little backround: The webserver is acually an open source linux firewall which i was able to edit the apache config file to host a second site. I just want the ability to store edit and display some network information within a very small site I made without the use of a database. Is this even possible? Hello, I've been looking around the web for a simple JavaScript to solve this problem but can't seem to find something that would work both in IE and FF and the other major browsers? So basically I have a page listing about a dozen badges people can use to link back to me. I have presented the code for each badge (eg. a href, img src, alt...) in a separate textarea and I'd really love to add a link next to each textarea that would say something like "Click here to copy to Clipboard" then it would copy the text from within the corresponding textarea to the Clipboard so as to eliminate the need for Ctrl+A, Ctrl+C. Thank you in advance people! |