JavaScript - How To Save User Entered Data In Javascript?
It will be best to use server side scripting like php for it , because user can disable his javascript in that condition your code won't work
Similar TutorialsHi, I am trying to write a small javascript program where I can call the following two functions and store information which a user enters. The problem is if I call the function a second time to add more information the array gets overwritten. info () insert (name, surname, favouriteColour) function info () { name = prompt ("Please enter your name."); surname = prompt ("Please enter your surname."); favouriteColour = prompt ("Please enter your favourite colour."); } function insert (name, surname, favouriteColour) { var info = new Array (); info.name = name; info.surname = surname; info.favouriteColour = favouriteColour; return info }; Help is really appreciated.. I have a JavaScript application that needs to preserve double quote marks and apostrophes (" and ') that are entered into form fields by the user. The form data is passed through several screens using hidden fields. Right now, apostrophes work because I have the input fields coded as value="". I have not found a way for JavaScript to retrieve the field's value if double quotes are entered by the user. If I change the parameter to value='' (single quotes) then the apostrophes probably won't work. Is there a straightforward way for JavaScript to retrieve the field value containing quotes, so that I can manipulate it into a different string that can be easily passed between HTML pages? Hello! First off, please excuse my ignorance. I am a bit new to the coding world. I want users to be able to enter data into a textbox on my site, and the data then be placed at the end of a specific url, followed by '.html'. For example, say my website is mysite.com. If someone enters in the word "John" in the textbox and clicks the 'Submit' button, the URL should now be: mysite.com/John.html Thanks in advance! I need help using javascript cookies to save the input users will fill in to many inputs within one form. I've never worked with cookies and I was wondering if someone could help me out here - the answers I've found searching the web do not work for me. Any help is appreciated, Thanks. I have a long survey form and once its submitted it gets recorded into a database. I would love to be able to save a PDF version of the HTML form with all their radio buttons and textfields filled out at the same time its submitted. It would need a unique name that matches their record in the database (maybe it pulls the data that was entered into one of the form fields for the name). Whether it gets uploaded to an ftp or just emailed to a mailbox doesn't really matter. The purpose of this is to basically have a visual interpretation of the data by a single user. Is something like this even possible? Hi, I got the following script to work the way I want it by adding new text inputs with new name values, but if there is data added and the add button is clicked again everything disappears. Is there any way to keep the data from going AWAL? Code: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <script> var counter = 0; function generateRow() { counter += 1; var d=document.getElementById("add_new"); d.innerHTML+="<p><input type='text' name='new_item" + counter + "'>"; } </script> </head> <body> <form id="form1" name="form1" method="get" action=""> <div id="add_new"></div> <p><input type="button" value="Add" onclick="generateRow()"/></p> <p> <label> <input type="submit" name="Submit" value="Submit" /> </label> </p> </form> </body> </html> Thanks much! EDIT: I was looking on Google and saw a JQuery method of doing it if someone has an idea of how to get this one to hold up.. 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 content="text/html; charset=utf-8" http-equiv="Content-Type" /> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script> <script type="text/javascript"><!-- $(document).ready(function(){ var counter = 2; $("#add").click(function () { if(counter==11){ alert("Too many boxes"); return false; } $("#textBoxes").html($("#textBoxes").html() + "<div id='d"+counter+"' ><label for='t2'> Textbox "+counter+"</label><input type='textbox' name='t"+counter+"' id='t"+counter+"' > </div>\n"); ++counter; }); $("#remove").click(function () { if(counter==1){ alert("Can u see any boxes"); return false; } --counter; $("#d"+counter).remove(); }); }); // --></script> </head> <body> <form id="form1" name="form1" method="get" action=""> <div id='textBoxes'> <div id='d1' ><label for="t1"> Textbox 1</label><input type='textbox' name='t1' id='t1' ></div> </div> <input type='button' value='add' id='add'> <input type='button' value='remove' id='remove'> <br/> <input type="submit" name="Submit" value="Submit" /> </form> </body> </html> Thanks again Hi, In Google Chrome the 'chrome.tabs.captureVisibleTab(integer windowId, function callback)' method will return a data URL of the JPEG encoding of the visible area of the captured tab. We want to save that content as image to hard disk without opening/passing the contents into new html page. Does anybody know how it can be done by javascript. Please provide help. Thanks. Hi, i'm having a problem with calling a netbeans function through an URL, that saves data to a postgresql table that has 119 columns. This is the original link: Code: http://www.mirodinero.com:8080/mirodinero-war/setMisDatos?callback=respuestaGuardarMisDatos¶m=%26usuario%3DIsa%20Mirodinero%26nivel%3D109%26gano_sal_neto%3D211113.45%26gano_sal_prof%3D2480%26gano_monet%3D0%26gano_renta_fija%3D0%26gano_renta_vble%3D0%26gano_inmuebles%3D2226.75%26gano_otros%3D2223.73%26gano_otros_ing%3D2411.12%26porc_gano_monet%3D0%26porc_gano_rentaf%3D0%26porc_gano_rentav%3D0%26porc_gano_inm%3D2%26porc_gano_otros%3D2%26porc_gano_otros_ing%3D1%26gasto_casa1%3D1306.46%26gasto_casa2%3D2402.38%26gasto_casa3%3D3999.57%26gasto_prestamo1%3D93475.58%26gasto_prestamo2%3D7325.88%26gasto_prestamo3%3D34090.9%26gasto_tarjetas%3D29443.2%26gasto_ibi%3D5670%26gasto_imp_otros%3D6780%26gasto_seg_inm%3D1320%26gasto_seg_pens%3D3451.22%26gasto_seg_vida%3D2330%26gasto_seg_plan%3D34230%26gasto_seg_medico%3D21220%26gasto_seg_coche%3D220%26gasto_luz%3D620%26gasto_agua%3D4550%26gasto_gas%3D320%26gasto_telef_f%3D22320%26gasto_telef_m%3D2350%26gasto_internet%3D20%26gasto_tv%3D3450%26gasto_hogar%3D20%26gasto_comida%3D20%26gasto_cenas_copas%3D20%26gasto_viajes%3D20%26gasto_vacaciones%3D220%26gasto_mobiliario%3D220%26gasto_ropa%3D2320%26gasto_transp%3D230%26gasto_otros%3D3620%26gasto_colegios%3D240%26gasto_univ%3D340%26gasto_master%3D2230%26gasto_otros_gastos%3D7323433%26porc_gasto_tarjetas%3D0%26porc_gasto_ibi%3D0%26porc_gasto_trib%3D0%26porc_gasto_seg_inm%3D0%26porc_gasto_seg_pens%3D0%26porc_gasto_seg_vida%3D2%26porc_gasto_seg_plan%3D2%26porc_gasto_seg_med%3D0%26porc_gasto_seg_coche%3D0%26porc_gasto_sum_luz%3D2%26porc_gasto_sum_agua%3D2%26porc_gasto_sum_gas%3D0%26porc_gasto_sum_teleff%3D0%26porc_gasto_sum_telefm%3D0%26porc_gasto_sum_int%3D0%26porc_gasto_sum_tv%3D0%26porc_gasto_nivel_hogar%3D0%26porc_gasto_nivel_comida%3D0%26porc_gasto_nivel_cenas%3D0%26porc_gasto_nivel_viajes%3D0%26porc_gasto_nivel_vacac%3D0%26porc_gasto_nivel_mob%3D0%26porc_gasto_nivel_ropa%3D20%26porc_gasto_nivel_transp%3D30%26porc_gasto_nivel_otros%3D30%26porc_gasto_colegios%3D2%26porc_gasto_univ%3D0%26porc_gasto_master%3D0%26porc_gasto_otros_gastos%3D23%26tengo_casa1%3D1231.11%26tengo_casa2%3D10000%26tengo_casa3%3D22240%26tengo_otras%3D23560%26tengo_monetario%3D1212.34%26tengo_planpensiones%3D23230%26tengo_otros%3D23330%26porc_tengo_casa1%3D1%26porc_tengo_casa2%3D0%26porc_tengo_casa3%3D2%26porc_tengo_otras%3D0%26porc_tengo_monet%3D0%26porc_tengo_plan%3D0%26porc_tengo_otros%3D0%26debo_casa1%3D4340%26debo_casa2%3D23450%26debo_casa3%3D23430%26debo_prestamo1%3D23330%26debo_prestamo2%3D6871.11%26debo_prestamo3%3D11340%26debo_tarjetas%3D61340%26porc_debo_casa1%3D30%26porc_debo_casa2%3D10%26porc_debo_casa3%3D12%26porc_debo_prestamo1%3D1%26porc_debo_prestamo2%3D12%26porc_debo_prestamo3%3D1%26porc_debo_tarjetas%3D4%26plazo_debo_casa1%3D230%26plazo_debo_casa2%3D450%26plazo_debo_casa3%3D122%26plazo_debo_prestamo1%3D3%26plazo_debo_prestamo2%3D12%26plazo_debo_prestamo3%3D4 It's 2568 characters long, so i guess that's why i get sometimes a GET undefined method in the web console. The original function does something like this: Code: var param ="&usuario="+usuario+"&nivel="+nivel+gano+porc_gano+gasto+porc_gasto+tengo+porc_tengo+debo+porc_debo+plazo_debo; var s = document.createElement("script"); s.type = "text/javascript"; s.async = true; s.src = server_direction +"setMisDatos?callback=respuestaGuardarMisDatos¶m="+encodeURIComponent(param); var h = document.getElementsByTagName("script")[0]; h.parentNode.insertBefore(s, h); //or h.appendChild(s); and every variable in the param is written like this: Code: var plazo_debo_casa1 = (getValor("plazo_debo_casa1")); var plazo_debo_casa2 = (getValor("plazo_debo_casa2")); var plazo_debo_casa3 = (getValor("plazo_debo_casa3")); var plazo_debo_prestamo1 = (getValor("plazo_debo_prestamo1")); var plazo_debo_prestamo2 = (getValor("plazo_debo_prestamo2")); var plazo_debo_prestamo3 = (getValor("plazo_debo_prestamo3")); var plazo_debo ="&plazo_debo_casa1="+plazo_debo_casa1+"&plazo_debo_casa2="+plazo_debo_casa2+"&plazo_debo_casa3="+plazo_debo_casa3+"&plazo_debo_prestamo1="+plazo_debo_prestamo1+"&plazo_debo_prestamo2="+plazo_debo_prestamo2+"&plazo_debo_prestamo3="+plazo_debo_prestamo3; since my webpage has different parts where to put the data, i thought that a good idea would be to create smaller function for parts of variable, for example putting 30 variables and the do the callback. I did like this: Code: function guardaLoQueGano(){ var nivel = parseInt(document.getElementById('progreso_nivel_total').style.marginLeft); /*idUsusario*/ var usuario = miGetElementsByClassName('title', document.getElementById('block-user-1'))[0].innerHTML; /*gano*/ var gano_sal_neto = getValor("gano_sal_neto"); var gano_sal_prof = getValor("gano_sal_prof"); var gano_monet = getValor("gano_monet"); var gano_renta_fija = (getValor("gano_renta_fija")); var gano_renta_vble = (getValor("gano_renta_vble")); var gano_inmuebles = (getValor("gano_inmuebles")); var gano_otros = (getValor("gano_otros")); var gano_otros_ing = (getValor("gano_otros_ing")); /*gano porcentajes*/ var porc_gano_monet = getValor("porc_gano_monet"); var porc_gano_rentaf = getValor("porc_gano_rentaf"); var porc_gano_rentav = getValor("porc_gano_rentav"); var porc_gano_inm = getValor("porc_gano_inm"); var porc_gano_otros = getValor("porc_gano_otros"); var porc_gano_otros_ing = getValor("porc_gano_otros_ing"); var param = "&usuario=" + usuario + "&nivel=" + nivel + "&gano_sal_neto=" + gano_sal_neto + "&gano_sal_prof=" + gano_sal_prof + "&gano_monet=" + gano_monet + "&gano_renta_fija=" + gano_renta_fija + "&gano_renta_vble=" + gano_renta_vble + "&gano_inmuebles=" + gano_inmuebles + "&gano_otros=" + gano_otros + "&gano_otros_ing=" + gano_otros_ing + "&porc_gano_monet=" + porc_gano_monet + "&porc_gano_rentaf=" + porc_gano_rentaf + "&porc_gano_rentav=" + porc_gano_rentav + "&porc_gano_inm=" + porc_gano_inm + "&porc_gano_otros=" + porc_gano_otros + "&porc_gano_otros_ing=" + porc_gano_otros_ing; var s = document.createElement("script"); s.type = "text/javascript"; s.async = true; s.src = direccion_servidor + "setMisDatos?callback=respuestaGuardarMisDatos¶m=" + encodeURIComponent(param); var h = document.getElementsByTagName("script")[0]; // adesso h.appendChild(s); h.parentNode.insertBefore(s, h); alert("Datos de lo que gano actualizados correctamente"); } This kind of function works perfectly, but has a big problem: it changes the values of the columns of this function, but deletes the remaining ones. How can I create different smaller function, in a way to save only on some columns without changing the others? Shall I write the netbeans function setMisDatos to make it more clear? This is code use to save XML file using Javascipt but it can't not save full Processing Instruction, example we have PI is <?xml version="1.0" encoding="utf8"> when run the code then PI is saved with <?xml version="1.0"> and sometime it doesn't word. Please help me fix, thanks PHP Code: function SaveXML(xmlDoc,filename) { var outputXML = xmlDoc.xml; var mfObj = new ActiveXObject("Scripting.FileSystemObject"); var absPath = getPath(); var file = mfObj.CreateTextFile(absPath + filename, true); file.Write(outputXML); file.Close(); } function getPath() { var path = document.location; var str = new String(path); var end = str.lastIndexOf("/"); var absolutePath = str.substring(8, end) + "/"; absolutePath = absolutePath.replace(/%20/g, " "); return absolutePath; } Hello, i m new Javascript but knows basics of functions etc. ive created a website, which also has field to Submit Email addresses for newsletters.. Now, i have a TextBox (for users to write email addresses) and a Submit button in which i want to call a Javascipt script function which OnClick takes the value(email address) from the textbox and saves it to a .txt file on server. i think i am just missing a single line, the function name which will store the value.. i searched ovr the net but didnt find it.. plz help mee. Thankyou! hi, i want to create a extension for chrome using which i can save the current tab url in a text file. thanks sanjay Hi to every one. I'w created a mini javascript game for my site where you click on red button as fastest as you can for 10 seonds to achieve as best as you can click numbers per second. And the end score is a variable which I send to a function which reads the array that contains ten best scores and write your score in same array if it's among 10 best. Now I want to make somehow to save that array on server so I could read it on page load to show a high score list, but I'm having trouble to write that array in any kind of data on server that I could read it again from same data. I would be very grateful if someone can help me! This article ( http://www.webreference.com/js/column24/userdata.html ) explains how to do userdata persistence, but (like most things in ie) the code is in the source. Anyone know if you can do user data persistence dynamically in ie? Could I create the requisite metatag and css rule on-demand, instead of in the source? Any tips/links welcome. Hello, I am looking for some strong resources about the topics above. I am trying to create a map for my website that visualizes Americas opinions on who will win the 2012 election... Obama vs the Republicans. I have a data set that will be the base, but I would like to update the map as users take the accompanying poll and as the data set changes. Any ideas or information would be awesome! Thanks 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! Hi guys, Great site by the way =). Basically if you view http://debtclock.co.uk/contact and click the form submit before inputting any details in the boxes you will see that the boxes highlight red to indicate there are some fields missing. Everything works fine, but if you view it on I.E 8 you can see that the red fill doesnt appear, only the text above it saying there are errors. Anyway I hope someone can get back to me with an idea, I am sat here in the office pulling my hair out not having an idea what it could be ><><>< Hello, I have been working on a website for a while now and have started working on user created accounts for my javascript login. Here is the code for the login: <h3 align="center"> Sign In</h3> <form id="Form1" onsubmit="login()"> <p align="center"> User Name: <input type="text" id="userid"></p> <p align="center"> Password: <input type="password" id="pswrd"></p> <p align="center"><input type="submit" value="Login"/> <input type="reset" value="Cancel"/></p> </form> <script language="javascript"> UNArray=["User1","User2","User3"] PWArray=["Password1","Password2","Password3"] function login(){ for(i=0;i<=UNArray.length;i++){ if(document.getElementById("userid").value==UNArray[i]){ if(document.getElementById("pswrd").value==PWArray[i]){ window.open("Home.html") } } } } Here is the code for the "Create An Account" page: <form id="form1"> Your First Name: <input type="text" name="firstname"> <br/> <br/> Desired Username: <input type="text" name="username"> <br/> <br/> Email (Optional): <input type="text" name="Email"> <br/> <br/> Password: <input type="password" name="password"> <br/> <br/> <input type="submit" value="Submit"> </form> Can Anyone help me with this? Thanks! I want to create this box. http://i31.tinypic.com/oqb12q.jpg I know i can do it with a iFrame, but i've heard they are quite vunerable to hacking. I already have my .php sorted to show the admin posted news on my site (Im alright at .php; rubbish and javascript). Was just wondering if there was a way to do it without using iFrames ? Spent past few days helping my son for his project of manipulating bouncing ball. Please help me this script work. Once user inputs the new ani value, the ball goes out. I want user to set any value ani, int and size of the ball to achieve desired animation. Seriously urgent... Thanks! <HTML> <HEAD> </HEAD> <BODY> <IMG ID="ball" STYLE="position: absolute; left: 325; top: 200; width: 30; height: 30;" SRC="images/ball1.gif"> <SCRIPT LANGUAGE="JavaScript"> function showAlert() { alert('ANI=' + ani + ', INT=' + int + ', SIZE=' + wxh + ''); } </SCRIPT> <SCRIPT LANGUAGE="JavaScript1.2"> <!-- var myBall = document.getElementById("ball"); var loc = 200; var ani = 10; var direction = 0; var int = 50; var wxh = 30; setInterval("myFunction()", int); function myFunction(){ if(0 == direction) { /* move down */ loc += ani; if(loc >= 500) { /* reached lower limit, change direction */ direction = 1; } } else { /* move up */ loc -= ani; if(loc < 10) { /* reached upper limit, change direction */ direction = 0; } } myBall.style.top = loc; } // --> </SCRIPT> <SCRIPT LANGUAGE="JavaScript1.2"> function readText (form) { if(form.f_ani.value != ""){ ani = form.f_ani.value ; myBall = document.getElementById("ball"); loc = 200; direction = 0; int = 50; setInterval("myFunction()", int); myFunction(); } showAlert(); } </SCRIPT> <FORM action="" method="Get"> Ball Movement (10 pixels):<input type='text' NAME="f_ani" value="10" size="20"><br> Interval (200 milliseconds):<INPUT type="text" id="f_int" value="200" size="20" name="1"><br> Ball Size (10 pixels W&H):<INPUT type="text" id="f_size" value="30" size="20" name="2"><br> <input type='button' value='Send' onclick="readText(this.form)"> <INPUT type="reset"> </FORM> </BODY> </HTML> |