JavaScript - Duplicate Text As You Type?
Is there a method or a way to duplicate the text typed in one textarea to another, with onkeyup or onchange?
The problem I'm facing is with FCKeditor. Two textareas with loaded templates and the text has to be manually copied and pasted when changed. Code: <form action="" method="post" name="form1" id="form1"> Subject:<br /> <input type="text" name="subject" value="Subject" size="32" /> <br /> Main Article:<br /> <textarea name="content" cols="50" rows="10"> <?php echo $row['article']; ?> </textarea> <br /> Text version:<br /> <textarea name="content_text" cols="50" rows="10"> <?php echo $row['article']; ?> </textarea> <input type="submit" value="Send" /> </form> I may be going about this all wrong? Send newsletters, it all works - not sure? do I need the second texarea. Similar TutorialsI have an input element of type=text. It has a fixed width, but I want to expand that width as the user is typing if the text doesn't fit inside. I did something similar to this with <textarea> and the vertical height. PHP Code: // javascript in mootools textarea.addEvent('keyup', function(){ textarea.setStyle('height', this.getScrollSize().y ); }); Does anyone know of a way to do this with <input type='text'>? Newbie here. I could not find the syntax how to set initial value he Code: var indat = window.clipboardData.getData ("Text"); . . . . . <input type="text" name="q" value="xxxxxx" size="40" /> I would like the value to be the indat var value I saw lot of samples with value="xxxxx" (hard coded value) but could not find sample for var value thanks for help !! Hi guys, Let me explain simply what I do and what I'm trying to achieve: I got a couple of comboboxes were the user selects a series of numbers. Once a selection is made, the value is appended to an input box. The idea is that the appended values form a telephone number, or at least part of one, that will then be used to search trough a database to look for a matching number. The code below is what I have done so far: Code: <script type="text/javascript"> function displayIndicatif(){ var sel = document.getElementById("indicatif"); var text = sel.options[sel.selectedIndex].value; var out = document.getElementById("blabla"); out.value += text+"\n"; } function displayBloc(){ var sel1 = document.getElementById("bloc"); var text1 = sel1.options[sel1.selectedIndex].value; var out1 = document.getElementById("blabla"); out1.value += text1+"\n"; } </script> [...] <input type="text" id="blabla"/> [..] <select id="indicatif" onChange="displayIndicatif();"> <option value="021">021</option> <option value="022">022</option> <option value="031">031</option> </select> <select id="bloc" onChange="displayBloc();"> <option value="555" class="021">555</option> <option value="666" class="021">666</option> <option value="777" class="021">777</option> </select> Basically what happens now is this: combobox indicatif: 021 | 022 | 031 combobox bloc: 555 | 666 | 777 If I select "021" from indicatif, the script will append 021 to the input "blabla". The problem is, if I now select "022", the input will show "021022" instead of replacing the 021 with 022. What I would like is that, for each combobox, the script replaces the selected value with the new one instead of simply appending it, like instead of say 021022555666 it would show 021555 or 022666 or 021666 depending on what is selected...you get the idea? Is this doable? Needless to say I'm a total noob at javascript...I adapted the code I got now from some other guy who was trying to achieve almost the same thing and adapted it to my needs, or least, tried to, but now I'm stuck. Any help is appreciated! Thanks I was just wondering how I could change a html text input tpe from text to password on the on click and when the user clicks off it will change back to text just like facebook does.
print "<Font face=\"calibri, Arial\"><table id=\"rnatable\" border=2px width=100%>"; print "<th></th>"; print "<th>a</th>"; print "<th>b</th>"; print "<th>c</th>"; print "<th>d</th>"; print "<th>e</th>"; print "<th>f</th>"; print "<th>g</th>"; while($array = mysql_fetch_array($sql_query)) { $id=$array['a']; print "<tr id=\"newtr\">"; print "<td><input id=\"check\" type=\"checkbox\" name=\"keyword[]\" value=\"$id\" ></td>"; print "<td>".$array['a']."</td>"; print "<td>".$array['b']."</td>"; print "<td>".$array['c']."</td>"; print "<td>".$array['d']."</td>"; print "<td>".$array['e']."</td>"; print "<td>".$array['f']."</td>"; print "<td> <a href=\"http://localhost/rnasearch/retrieve.php?a=$id\">bla</a> </td></tr></font>"; } print "</table>"; } this is part of a php searchengine script that i wrote to retrieve data from a database and as you can see the last column that is g contains a link which when clicked takes the user to the second php script which retrieves additional information of that entry, but this is done for only single entries so as you can see i introduced checkboxes so that the user can check any number of checkboxes and retrieve information as per their wish now to do this i created a <input type=text where i want the value of these checkboxes i.e. $id to be posted in a delimited format so that the user can then click the corresponding button and retrieve the information this is the code <div id="floatMenu"> <ul class="menu1"> <center><li><form name="senddata" method="POST" action="http://localhost/retrieve.php" style="display:inline;"><input id="fasta" type="text" class="multitext"><input name="Fasta" type="Submit" value="Retrieve Fasta"></form> this is a css floating menu....so far so good....everything went fine.... after this i had to write a javascript to do this and i've been stuck there searching forums for the last 4 days! this is the javascript i found from somewhere which came close to doing wht i wanted it to do window.onload = function () { var cb = document.getElementById('check'); var fasta = document.getElementById('fasta'); cb.onclick = function () {fasta.value = cb.value + ","; };}; this script only sends the value of the first checkbox in the table, the others are not found by it, mind you its not the first checkbox selected its the first checkbox that is present in the table how can i resolve this problem so that even if i have n number of checkboxes in my table, if the user chooses to do so they can retrieve n number of information....please help i've almost lost hope in this! I need to change input type="text" to input type="password" via JavaScript Code: <form id="login" action="#" method="post"> <input id="username-field" type="text" name="username" title="Username" onmousedown="javascript:this.value=''; javascript:this.focus();" value="Username" tabindex="1" /> <input id="password-field" type="text" name="password" title="Password" onmousedown="javascript:this.value=''; javascript:this.type='password'; javascript:this.focus();" value="Password" tabindex="2" /> <input type="submit" name="submit" value="sign in" tabindex="3" /> </form> This works in Firefox and Safari but not IE So then I tried this code Code: <script type="text/javascript"> function passit(ip){ var np=ip.cloneNode(true); np.type='password'; if(np.value!=ip.value) np.value=ip.value; ip.parentNode.replaceChild(np,ip); } </script> <form id="login" action="#" method="post"> <input id="username-field" type="text" name="username" title="Username" onmousedown="javascript:this.value=''; javascript:this.focus();" value="Username" tabindex="1" /> <input id="password-field" type="text" name="password" title="Password" onmousedown="javascript:this.value=''; passit(this.form[0]); javascript:this.focus();" value="Password" tabindex="2" /> <input type="submit" name="submit" value="sign in" tabindex="3" /> </form> This does what I need but turns the username type to password field not the password box Please can somone help! suggestions welcome !!
Hello Guys and Gals, I have got my head around using the jquery validate and submit without refresh and implemented it successfully on a front end form. Now I would like to streemline backend updating by enabling submit without refresh for multiple items on a page, validation would be nice but less important. what I would like to do is something like adding 'here' to the function and 'this' to the form but im not sure how exactly. here is the code im using Code: <title>Untitled Document</title> <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js'></script> <script type="text/javascript" src="js/jquery.validate.js"></script> <script type="text/javascript" src="js/jquery.form.js"></script> <script type="text/javascript"> $('document').ready(function(){ $('#form').validate({ rules:{ // your validation rules }, messages:{ // and validate msgs }, submitHandler: function(form){ $(form).ajaxSubmit({ target: '#preview', success: function() { // take these lines out if you dont want to hide the form after submit $('#formbox').slideUp('slow'); ///////////////// } ///////////////////////////////////////////// }); } }) }); </script> </head> <div id="preview"> </div> <div id="formbox"> <form id="0" name="0" method="post" action="timbersend.php" > <label>name</label> <input type="text" name="name" /> <label>value</label> <input type="text" name="value" /> <input type="submit" value="submit" name="submit" /> </form> </div> <body> </body> thanks steve I would like to count how many duplicate values I have in an array. My below attempt doesnt count the duplicate values: Code: var ct = 0; for(var i = 0;i < myArray.length;i++) { var myData = getData[i].city; if(myData == myData) { ct++; } alert("Total Count = " + ct); } Please advise the best way to do this. disregard...i got it
Hi, on my page below: http://www.jbiddulph.com/helix/events.html I have a navigation of 1,2,3,4,5which when a user clicks on a different number the image changes, I need to have this navigation for the 4 other large boxes underneath?! I can't work out how to go about this?! please help here is the code to the page Code: <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Helix</title> <link type="text/css" rel="stylesheet" href="css/reset.css"> <link rel="stylesheet" type="text/css" href="css/style.css" title="default" /><!--[if lte IE 7]> <style type="text/css"> html .jqueryslidemenu{height: 1%;} /*Holly Hack for IE7 and below*/ </style> <![endif]--> <script type="text/javascript" src="js/jquery-1.3.2.min.js"></script> <script type="text/javascript" src="js/jquery.cycle.all.min.js"></script> <script type="text/javascript"> $(function() { $('#slideshow').after('<div id="nav" class="nav">').cycle({ fx: 'fade', speed: 'fast', timeout: 0, pager: '#nav', befo onBefore }); function onBefore() { $('#title').html(this.alt); } }); </script> </head> <body> <div id="top"> <div id="topwrapper"> <div id="logo"> </div> <ul id="rightnav"> <li><a href="index.html" title="Home">Home</a></li> <li><a href="news.html" title="News">News</a></li> <li><a href="archives.html" title="Archives">Archives</a></li> <li><a href="finishes.html" title="Finishes">Finishes</a></li> <li><a href="contact.html" title="Contact">Contact</a></li> </ul> <nav> <ul> <li><a href="events.html" title="HELIX EVENTS" class="menuselected">HELIX EVENTS</a></li> <li><a href="marketing.html" title="HELIX MARKETING">HELIX MARKETING</a></li> <li><a href="film.html" title="HELIX FILM & TV">HELIX FILM & TV</a></li> <li><a href="exhibitions.html" title="HELIX EXHIBITIONS">HELIX EXHIBITIONS</a></li> <li><a href="interiors.html" title="HELIX COMMERCIAL INTERIORS">HELIX COMMERCIAL INTERIORS</a></li> </ul> </nav> <div class="line"> </div> </div> </div> <div id="content"> <section id="slider" style="background-color: rgb(160, 191, 74);"> <div id="viewport"> <div id="container"> <div id="section-1" class="section"> <img src="images/slider_01.png"> </div> </div> </div> </section> <div class="line"> </div> <h1>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</h1> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p> <div class="dashedlinetop"> </div> <div id="box"> <div id="slideshow" class="pics"> <img src="images/box1.jpg" alt="1"/> <img src="images/box2.jpg" alt="2"/> <img src="images/box3.jpg" alt="3"/> <img src="images/box4.jpg" alt="4"/> <img src="images/box5.jpg" alt="5"/> </div> </div> <div class="dashedlinebottom"> </div> <div class="dashedlinetop"> </div> <div id="box"> <div id="slideshow" class="pics"> <img src="images/box1.jpg" alt="1"/> <img src="images/box2.jpg" alt="2"/> <img src="images/box3.jpg" alt="3"/> <img src="images/box4.jpg" alt="4"/> <img src="images/box5.jpg" alt="5"/> </div> </div> <div class="dashedlinebottom"> </div> <div class="dashedlinetop"> </div> <div id="box"> <div id="slideshow" class="pics"> <img src="images/box1.jpg" alt="1"/> <img src="images/box2.jpg" alt="2"/> <img src="images/box3.jpg" alt="3"/> <img src="images/box4.jpg" alt="4"/> <img src="images/box5.jpg" alt="5"/> </div> </div> <div class="dashedlinebottom"> </div> <div class="dashedlinetop"> </div> <div id="box"> <div id="slideshow" class="pics"> <img src="images/box1.jpg" alt="1"/> <img src="images/box2.jpg" alt="2"/> <img src="images/box3.jpg" alt="3"/> <img src="images/box4.jpg" alt="4"/> <img src="images/box5.jpg" alt="5"/> </div> </div> <div class="dashedlinebottom"> </div> <div class="dashedlinetop"> </div> <div id="box"> <div id="slideshow" class="pics"> <img src="images/box1.jpg" alt="1"/> <img src="images/box2.jpg" alt="2"/> <img src="images/box3.jpg" alt="3"/> <img src="images/box4.jpg" alt="4"/> <img src="images/box5.jpg" alt="5"/> </div> </div> <div class="dashedlinebottom"> </div> </div> <!-- end content --> </body> </html> OMG, Check out the background on this site... http://paulirish.com/ how would I even start to rip that for use on my own site? I'll pay someone $15 on paypal if they can make a css and js file that I can just link too and have this background
Greetings and salutations. My text and what I have been researching on the internet has not been very helpful in determining the code that I need to prevent a user from entering his/her information more than once. Here is my current code Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD.HTML 4.01 Transitional//EN" "http://www.w3.org/TR/htm14/loose.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Kudler Fine Foods Contact Page</title> <meta http-equiv="Content-type" content="text/html; charset=iso-8859-1"> <!---Kami Demnyan 21 December 2009--> <script type="text/javascript"> /*<![CDATA[*/ <!--This code ensures that the zip code and telephone numbers are actual numerical digits, not letters--> function checkForNumber(fieldValue) { var numberCheck = isNaN(fieldValue); if (numberCheck == true) { window.alert ("Please enter a numerical value"); return false; } } <!--This code ensures that all of the fields contain text and I have it functioning now--> function submitForm() { if (document.forms[0].name.value == "" || document.forms[0].address.value == "" || document.forms[0].city.value == "" || document.forms[0].state.value == "" || document.forms[0].zip.value == "" || document.forms[0].phone.value == "" || document.forms[0].email.value == "") { window.alert("Please enter your missing information"); return false; } else return true; } function getCookie(NameOfCookie) { if (document.cookie.length > 0) { begin = document.cookie.indexOf(NameOfCookie+"="); if (begin != -1) { begin += NameOfCookie.length+1; end = document.cookie.indexOf(";", begin); if (end == -1) end = document.cookie.length; return unescape(document.cookie.substring(begin, end)); } } return null; } function setCookie(NameOfCookie, value, expiredays) { var ExpireDate = new Date (); ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000)); document.cookie = NameOfCookie + "=" + escape(value) + ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString()); } function delCookie (NameOfCookie){ if (getCookie(NameOfCookie)) { document.cookie = NameOfCookie + "=" +"; expires=Tues, 02-Feb-10 00:00:01 GMT"; } } /*]]>*/ </script> </head> <body> <h1> KUDLER FINE FOODS </h1> <h2> JOIN OUR MAILING LIST</h2> <!--This is where the user will input all of their information to join the mailing list--> <form action="completeform.html" method="get" onsubmit="return submitForm();" enctype="application/x-www-form-urlencoded"> <p>Name<br /> <input type="text" name="name" size="50" /></p> <p>Address<br /> <input type="text" name="address" size="50" /></p> <p>City, State, Zip <br /> <input type="text" name="city" size="30" /> <input type="text" name="state" size="3" /> <input type="text" name="zip" size="10"; onchange="return checkForNumber(this.value)"; /></p> <p>Telephone<br /> <input type="text" name="phone" size="25" onchange="return checkForNumber(this.value)"; /></p> <p>Email Address<br /> <input type="text" name="email" size="50" /></p> <!--This is where the submit and reset buttons are located--> <p><input type="submit" value="Submit Form" /> <p><input type="reset" value="Reset Form" /> </form> </body> </html> I have created a new web page to link the duplicate cookie too, titled doubleinfo.html. This is what I am using to let the user know that their information has already been entered. My text is telling me that I need to look for a nextform() function, but I didn't have to write one so what would I need to do, if anything, to start the document.cookie = "name" codes? Any help would be greatly appreciated, thanks in advance. Hello Guys, im writing a big page with several different elements in it, and im stuck trying to duplicate a script. first one works "tab b" click each 'icon' and a .png file appears above it to show its selected. "tab c" same script and code seems to only work for first icon, and switch off when clicked on the others. been staring at this for sooooome time now, please can someone see what i have done wrong, as i dont really understand the code im using, im just a beginner. url is http://www.zakscustomcues.com/module...builder2.0.php much appreciated. steve Hi there It's huge problem for me but I don't think it is for many of you here. I have been asked at the college to make a manual lottery checker using javascript, but I found lots of problem during the coding. To make it more clear it's about 3 players they always play the same set of 6 number between 1 and 49. the players enter manually the winning number using a prompt which popup when you open the page (No button required for this, just simple prompt). each time you type duplicate number an alert tells that this number been entered, when the six number been successfully entered will ask for the bonus ball the same way but it should between 1 and 49 as well. When this done the program print out for each player the much numbers. This my peace of coding but I stucked in many bits in it. I need your knowledge guys in javascript to fix this for me. Code: <html> <head> <title>Lottery Checker</title> <h1>Lottery Checker</h1> </head> <body> <script type="text/javascript"> //Declare Variable var number1 = [3, 9, 18, 27, 30, 33]; var number2 = [5, 7, 11, 12, 34, 42]; var number3= [4, 15, 21, 23, 27, 31]; var drawNumber = []; var bonusBall = []; //Declare variable Times and Dates var currentTime = new Date(); var day = currentTime.toUTCString(); // Print out the player set numbers document.write("<h4>You visited the lottery website at :</h4>" + day); //Print out Times and Dates document.write('<p>Player number 1 : '+ number1 +'</p>'); document.write('<p>Player number 2 : '+ number2 +'</p>'); document.write('<p>Player number 3 : '+ number3 +'</p>'); //Copare Lottery Number arrays //Add input number using prompt to add the 6 bonus number and the bonus ball for (var i=0 ; i<=5 ; i++) { drawNumber[i] = prompt("Enter the Lottery draw Number."); drawNumber.sort(function(a, b){return a-b}); //Fix the lottery Numbers between 1 and 49 while (drawNumber[i]<1 || drawNumber[i]>49) { drawNumber[i] = prompt("The lottery Number should be between 1 and 49"); // to insert Prompt insteat the Alert } if (drawNumber[i] = drawNumber) // if statement to be checked again { alert('You already entered this number');// if statement to be checked again } } document.write('<p>The winning lottery number for this week: '+drawNumber+ ', The bonus number: '+ drawNumber[6] + '</p></br>'); //Sort the winning number by each player // Display the result for each player how many number much document.write('Player 1 winning numbers: ' + drawNumber +'</br>'); document.write('Player 2 winning numbers: ' + drawNumber +'</br>'); document.write('Player 3 winning numbers: ' + drawNumber +'</br>'); </script> </body> </html> Hi Experts, I have an online application form that a member submits to register with our organization. However I want to make sure that the member submits only one application form per session year. Is there anyway I could setup a java script that lets the member know that they have already submitted their application when they try to re-submit. The current setup lets them submit many applications which I am trying to prevent. Any help is greatly appreciated. Thanks Vinny Hi, I would like to prevent the addition of duplicate items in the following situation. Firstly, I have a listbox with a few options such as Code: <select id="listbox" name="listbox" multiple="multiple" style="width: 580px;"> <option>Java</option> <option>PHP</option> <option>Perl</option> <option>Javascript</option> <option>C#</option> <option>Powershell</option> </select> Next, I have a submit button with a textbox. The user will be able to submit new options into the listbox via the textbox and submit button. Therefore, I need to prevent the user from entering duplicate items into the listbox. How should I do? The following code is used to add items into the listbox. Code: function addItem() { var lst = document.getElementById('listbox'); // listbox control id var newItem = prompt("Enter New Item","Enter Value Here"); //Option object is created for every option in a selection //new Option([text[, value[, defaultSelected[, selected]]]]) // Syntax if(newItem == null) { return false; } else { lst.options[lst.length] = new Option(newItem,newItem,false,false); return false; } } Hi everyone, now I need to add items into a dropdown list, and the items would be sorted alphabetically and it does not allow duplicate items to be added. Can anyone help take a look and see what's wrong with my code? Javascript Code: function addAnotherOption() { var newItem = document.getElementById("Text44"); if (!newItem.value == "") { var answer = confirm ("Are you sure you want to add? ") if (answer)//if answer is true { var lst = document.getElementById('comboBox'); // listbox control id // Now we need to create a new 'option' tag to add to MyListbox var newOption = document.createElement("option"); newOption.value = newItem.value; // The value that this option will have newOption.innerHTML = newItem.value; // The displayed text inside of the <option> tags for (var i = 0; i < lst.options.length; i++) { arrTexts = lst.options[i].text; if (arrTexts.toLowerCase() == newItem.toLowerCase()) { alert ("That option is already included in the list - please enter another item."); return false; } else { // Finally, add the new option to the listbox lst.appendChild(newOption); //sort items in listbox in alpha order arrTexts = new Array(); for(i=0; i<lst.length; i++) { arrTexts[i] = lst.options[i].text; } arrTexts.sort(); for(i=0; i<lst.length; i++) { lst.options[i].text = arrTexts[i]; lst.options[i].value = arrTexts[i]; } } } } } else { if(newItem.value == "") { alert("Key something to textbox please."); } else alert("Cancelled."); } } HTML Code: <input id="Text44" type="text" /> <input id="Submit22" type="submit" value="Add" onclick="addAnotherOption()" /><br /> <select name="combo" id= "comboBox" style="width: 323px"> <option value="H">Hearts</option> <option value="D">Diamonds</option> <option value="C">Clubs</option> <option value="S">Spades</option> </select> i've written a js function to find the difference between two dates. the format being used is dd/mm/yyyy hh:mm. The function returns correct value when give one set of values, but go wrong with another set. examples are given below. set 1 : Time 1 = 24/02/2011 09:30 , time 2 = 24/02/2011 16:00 Output is corret here. It gives 6 Hours & 30 Minutes (after converting the difference) set 2: Time 1 = 24/02/2011 09:30 , time 2 = 25/02/2011 16:00 Here, it gives 31 days, 6 Hours & 30 Minutes. My code is given below. Also the alert of dates display strange values. Don't know if it is timezone issue. I wonder what is going wrong here Code: function compareDateTime(frmtime,totime) { var date1 = new Date(frmtime); var date2 = new Date(totime); var diff = new Date(); alert(date1); alert(date2); diff = (date2.getTime()-date1.getTime()); if (diff<0) { alert("From Time cannot be later than To Time!"); return 0; } else if (diff==0) { alert("From Time cannot be equal with To Time!"); return 0; } else { return diff; } } The returned diff value is broken down as following: Code: if (diff>0) { days = Math.floor(diff / (1000 * 60 * 60 * 24)); diff -= days * (1000 * 60 * 60 * 24); hours = Math.floor(diff / (1000 * 60 * 60)); diff -= hours * (1000 * 60 * 60); mins = Math.floor(diff / (1000 * 60)); alert(days+","+hours+","+mins); return true; } Please Help... |