JavaScript - Change Input With Value From Table
I'm trying to change a row of input fields to have the value(s) of a table row.
When I click a button called Next, I want to pull in the value(s) that are already on the display. If I click Next again, I want to pull in the next row's values or if I click the button called Previous I want to get the prior lines values. Can someone please help or push me in the right direction? Thanks. Code: <script type="text/javascript"> function copyLine() { document.getElementById("pitem").value=document.getElementById("p1item").value; document.getElementById("ploc").value=document.getElementById("p1loc").value; document.getElementById("plot").value=document.getElementById("p1lot").value; document.getElementById("pqty").value=document.getElementById("p1qty").value; } </script> <table> <tr> <td><input type="text" name="item" id="pitem" size="15" value=""></td> <td><input type="text" name="loc" id="ploc" size="7" value=""></td> <td><input type="text" name="lot" id="plot" size="7" value=""></td> <td><input type="text" name="qty" id="pqty" size="10" value=""></td> </tr> <tr> <td><input type="button" value="Next" onclick="copyLine()"> <input type="button" value="Previous" /></td> </tr> <tr> <td id="p1item">Item 1</td> <td id="p1loc">Location 1</td> <td id="p1lot">Lot 1</td> <td id="p1qty">100</td> </tr> <tr> <td id="p2item">Item 2</td> <td id="p2loc">Location 2</td> <td id="p2lot">Lot 2</td> <td id="p2qty">200</td> </tr> <tr> <td id="p3item">Item 3</td> <td id="p3loc">Location 3</td> <td id="p3lot">Lot 3</td> <td id="p3qty">300</td> </tr> </table> Similar TutorialsStill need assistance, thanks Okay, so here's an example code of what I'm needing: Code: <html> <head> <title></title> <style type="text/css"> #greenrow { background-color:#090; } #redrow { background-color:#F00; } </style> <script type="text/javascript"> if (calculate.level.value >= calculate.getElementById('shrimp').value){ class = greenrow; } else { class = redrow; } </script> </head> <body> <form name="calculate"> <table> <tr> <td><label> Level<input name="level" type="text" size="5" /></label> </td> </tr> <tr id="shrimp"> <td>Shrimp</td> <td align="center"><label> <input type="text" name="shrimp" /> </label></td> <td colspan="3" align="left">10</td> </tr> </table> </form> </body> </html> Okay so what I want to be done is to get information from the input text area "level" and IF "level" is >= 10...for this one certain row, I want it to get the class #greenrow. Else, class = #redrow. Thanks hi i wants to change one input to texarea when i select one from radio, plz any suggestion how i would do that? my code PHP Code: <input type="text" name="other" value="this need to become textarea" /> <input type="radio" name="inputtext" />Text <input type="radio" name="inputtext" />Textarea so when i click inputtext radio name"other" will become a textrea rather then input type text. thanks for any help. Hi there, I'm working on a site: ocmd.co.nr And it features a lot of handy little web gadgets and apps for users. I was interested in creating a page, where two iframes are shown side-by-side both with the width of 50% and the height of 100%, with adressbars on top of each of them. So, essentially, what I need is just a code that allows the user to edit the iframe's src and get it to a different site. I wrote a function, to change a input value to show a key, which PHP later recognizes and makes addition changes too. However I can't seem to get this simple function to work, can you see anything wrong with it? Code: function quote(id) { var shout = document.getElementById('shout'); var currentShout = '; '.shout.value; var prefix = '@'.id; shout.value = prefix.currentShout; } I call it by Code: <a href="#" onclick="javascript: quote('2');">Comment</a> the input that changes is written as Code: <input id="shout" name="shout" type="text" onKeyPress="return submitenter(this,event);"> Hello, I am trying to change the value of #name and #category inputs based on the value of select. A friend gave me the code below, but I can't get it to work. Thanks so much for your help Code: <script type="text/javascript"> $('#Gift_Type').change(function(){ if ($(this).val() == 'Monthly'){ $('#name').val('Partnership') $('#category').val('Partnership') } else { $('#name').val('Donation') $('#category').val('Donations') } }) </script> Code: <SELECT NAME="sub_frequency" ID="Gift_Type" onchange="OnSelectionChanged (this)"> <OPTION VALUE="1m">Monthly</OPTION> <OPTION VALUE="">One Time</OPTION> </SELECT> Code: <input type="text" id="name" name="name" value="Partnership" /> <input type="text" id="category" name="category" value="Partnership" /> I have a script where I need to change input values automatically, and I just can't find the right code for it. Here's a little of my code below, can anyone help me, please? Code: document.getElementById("Id").innerHTML="Text here"; How do I change a text input's background when the user hits "Enter" or Key #13. The text-input field currently light's up to blue when hovered over, then it turns green when it is focused on, and now I want it to turn pink when you submit it. (This can be seen at http://ocmd.co.nr/ap) ------------------ Also, if anyone knows how I can redirect the user depending on there input, that'd be great. Regularly, it just runs a Google Search, but if I could get it so that when someone typed in, "chat room 1" for example, it'd open up a link or a new window w/ that. I have a problem thats above my head, im new to javascript. I want to be able to control the first three characters of an input string on a login form. If a user types GP15555 or JP15555 I want it to change to GPL5555 or JPL5555 respectively changing the "1" to an "L" on the prefix is this at all possible? any point in the right direction would be great. heres my code Code: </script> <script language="JavaScript" type="text/javascript"> //<![CDATA[ function Login(form) { var password = form.password.value; var pin = form.pin.value; var product = form.product.value; if (password) { var htsite = product + "/" + password + "/" + pin + "/index.html"; window.location = htsite; } else { alert("Please enter your password and pin."); } } // End --> //]]> </script> /thanks gp I'm trying to use an onclick function in a radio button to change the value of a hidden input in another form. What I want to happen is, when the user changes the value of the radio button (0 or 1), the value of the input named 'repeat' is set to 0 or 1 accordingly. The goal being that when I submit the form with input name='repeat' it will send the number indicated by the radio button. (Due to the structure of my page the radio button and the hidden input need to be two separate forms, but I don't think that should be a problem.) The code below isn't working -- the alert("changerepeat called") never even appears. It seems like the problem is that the onclick isn't even activating at all. Any ideas? Code: <script type="text/javascript"> function changerepeat(theval) { alert("changerepeat called"); document.forms[0].elements[0].value = theval; } function tellme() { alert("repeat = "+document.forms[0].elements[0].value); } </script> <form> <input type='hidden' name='repeat' value=''> <input type='button' value='tellme' onclick='tellme()'> </form> <form> <input type='radio' name='changerepeat' onclick='changerepeat(\'0\')'> 0 <input type='radio' name='changerepeat' onclick='changerepeat(\'1\')'> 1 </form> Thanks very much for reading! Hi! I want to insert flash player on my page, that user can change flv source. But I dont know how to make input field that change flv source. I tried to insert input field and button but dont know how to make it working, please help me Here is my flvplayer embed code: <script type="text/javascript" src="http://flvplayer.com/free-flv-player/flvplayer/swfobject/swfobject.js"></script> <div id="embed_player"> <h1>Please Upgrade Your Flash Player</h1> <p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p> </div> <script type="text/javascript"> var flashvars = { flvpFolderLocation: "http://flvplayer.com/free-flv-player/flvplayer/", flvpVideoSource: "http://flvplayer.com/media/audi_tdi_commercial.mp4", flvpWidth: "640", flvpHeight: "375", flvpInitVolume: "50", flvpTurnOnCorners: "true", flvpBgColor: "#FFFFFF" }; var params = { bgcolor: "#FFFFFF", menu: "true", allowfullscreen: "true" }; swfobject.embedSWF("http://flvplayer.com/free-flv-player/FlvPlayer.swf", "embed_player", "640", "375", "9.0.0", "http://flvplayer.com/free-flv-player/flvplayer/swfobject/expressInstall.swf", flashvars, params); </script> I have been working on this code for a few days now and it works. Or at least it appears to be working. I would like to have the tot 1, tot 2, tot 3 return with currency formatting. Is there a way to add something to my code to accomplish this? Thank you in advance for any suggestions. Regards Code: <html> <head> <script type="text/javascript" src="autoCurrency.js"></script> <script type="text/javascript"> function doCalc() { var v1 = document.getElementById('value1').value; var v2 = document.getElementById('value2').value; var v3 = document.getElementById('value3').value; document.getElementById('total1').value = ((v1*5)+(v2*1)) * (1-v3/100); document.getElementById('total2').value = ((v1*10)+(v2*1)) * (1-v3/100); document.getElementById('total3').value = ((v1*15)+(v2*1)) * (1-v3/100); } </script> <style type="text/css"> button { width: 80px; } input { margin: 10px 0; } input[type='text'] { width: 50px; } </style> </head> <body> <div> <input id="value1" type="text" value="0" /> <br /> </div> <div> <input id="value2" type="text" value="0" /> <br /> </div> <div> <input id="value3" type="text" value="0" /> <br /> </div> Tot 1:<input id="total1" type="text" /><br /> Tot 2: <input id="total2" type="text" /><br /> Tot 3: <input id="total3" type="text" /><br /> <button class="long" onclick="doCalc();">Calculate</button> </body> </html> Hello all i have to implement simple LIFO algorithm ( if i can call it like this .. ) say i have html table and and i fetching data i like thet the last data that fetched to be the first record in the table for example : im fetching the string "111" so it will be the first record next im fetching the string "222" now the string "111" will be the second and the string "222" will be the first .. and so on Hi there, I am a new javascript guy - struggling a bit but marching on - The following code works fine to set a form field - Code: document.getElementById("ZS_Land").value = (empLand.innerHTML); However, I changed to form field into a select with option list, and I need it to set an option from the select now - the select has the same name/id as the field had, but is not working Any ideas how I do that ? Many thanks in advance Glorifindal Hello, I'm currently working on http://footytweets.co.uk and would like to add an input field to my twitter feed widgets, which allows users to change which twitter account tweets are dispalyed. An example is here; https://twitter.com/about/resources/...widget_profile You can see in the example how you can enter a different twitter user account, then hit 'test settings', leading to related twees being displayed. I can see how to do it but Im a super novice at JS so thought Id ask for assistance . Any code help is very much appreciated. Thx Hi, what would be the best way to have a hidden array of possible text directed at a textarea and then if something is not within that array "onfocus", a certain select option is chosen within that form? Thanks 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! like for example i have text areas named upload1 and upload2 when I click or add input on upload1 a drop down list below upload2 will not change, but when I add input on upload2 the dropdown will select "parts" Hi, I'm very new to Javascript and I'm stuck. I am trying to create a js script that will prompt the user for a times table (example the 5 times table, the 7 times table, etc.) & prompt the user for 2 more values; the 'start' number and 'end' number. So there would be 3 numbers total the user must input. The script should present a 'warning' message if the user inputs letters or negative numbers. I have come very close to getting it too work but can't quite get past the last hurdle. Upon entering the 3 numbers, the output should look similar to this: (the 5 times table starting with 1 and ending with 12) The 5 times table 5 * 1 = 5 5 * 2 = 10 5 * 3 = 15 5 * 4 = 20 5 * 5 = 25 5 * 6 = 30 5 * 7 = 35 5 * 8 = 40 5 * 9 = 45 5 * 10 = 50 5 * 11 = 55 5 * 12 = 60 I have placed the js script code on pastebin.com and below. The pastebin link is: http://pastebin.com/2NZPiFH9 Code: function writeTimesTable(timesTable, timesByStart, timesByEnd) { for (;timesByStart <= timesByEnd; timesByStart++) { document.write(timesTable + " * " + timesByStart + " = " + timesByStart * timesTable + "<br>"); } } var timesTable; while ( (timesTable = prompt("Enter the first number in the times table. Enter -1 to exit.", -1)) != -1) { while (isNaN(timesTable) == true) { timesTable = prompt(timesTable + " is not a valid number, please retry.",-1); } if (timesTable == -1) { break; } document.write("<br>The " + timesTable + " times table<br>"); writeTimesTable(timesTable,1,12); } Hi all, What I am trying to achieve. I have a php page that has a button on it when clicked shows a div (previously hidden) in the middle of the page this div contains a table with rows. Each row has an image acting as a button and a series of fields that are populated from a database. One of the fields is a quantity box I want to be able to change the value in this box and click on the submit img and have it submit this info (including the altered quantity) back to the php page or to the submit function so that I can then access the values. I have absolutly no idea how to start this. I have very limited javascript experience. the submit looks something like (at the moment) Code: echo '<a href="#" onclick="javascript: document.getElementById(\'stockitemid\').value = '.$stockline->purchaseitemid.'; submitbutton(\'addLineFromStock\')" >'.$purchaseLineImg.'</a>'; and then I was trying to alert in the submit function something like: Code: alert(document.getElementById('stockitemid').value); my div td fields look like Code: <td> <input type="text" size="3" name="sid[<?php echo $stockline->purchaseitemid; ?>]" id="stockitemid<?php echo $count; ?>" value="<?php echo $stockline->purchaseitemid; ?>" /> </td> <td> <input type="text" size="3" name="stockqty[<?php echo $stockline->purchaseitemid; ?>]" id="stockquantity" value="<?php echo $stockline->quantitysupplied; ?>" /> </td> Any help would be greatly appreciated Thanks Kate Hello, I am trying to change the background color of a table based on the value of a picklist. For instance. if the picklist value was "1", then the background color of the table should be red. Not sure where I went wrong in my code. Code: <html> <body> <script type="text/javascript"> if (level="1") { levelColor = #FF0000; } </script> <select name="level"> <option value="1">1 <option value="2">2 <option value="3">3 <option value="4">4 <option value="5">5 </select> <br><br> <center> <table name="levelColor" width="700px" height="100px" cellspacing="0" cellpadding="0" border="1"> <tr> <td><center>This is the level.</center></td> </tr> </table> </center> </body> </html> Please help. Thank you. |