JavaScript - How Would I Make An Input Box?
like, for user and password on a site
I'm still pretty new to this Similar TutorialsOk, so if you navigate ovr to my website "http://www.mancunianmacca.co.cc" you will notice that a box pops up asking for your name. When you type it in it adds it to the page. Is there a way I can get this to remember the users input and only ask them once then remember. Like cookie or anything. If you need any extra things. Just ask.
I have a problem with adding new inputs to a form (if and when required), Internet Explorer is fine but in Firefox if any previous input fields are filled when the more button is clicked they get reset to blank. JS: Code: fields = 0; function addInput() { if (fields != 100) { document.getElementById('input').innerHTML += "<input type='text' name='input[]' size='30' />"; fields += 1; } else { document.getElementById('input').innerHTML += "<br />Maximum 100 fields allowed."; document.form.add.disabled=true;} } form: Code: <form action="index.php" method="post"> <div id="input"> <input type="text" name="input[]" size="30" maxlength="15" /> </div> <!-- button --> <div id="more"> <input type="button" onclick="addInput()" name="add" value="More" /> </div> <!-- // button --> <input type="submit" name="submit" value="Submit" /> </form> as usual any help is appretiated .. 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. Hi, i want to set an input value to the same value as the input selected from another input on the same form so when the user selects input 1 i want the hidden input2 to get the same value im guessing i use onsubmit because its hidden so there wont be a focus or blur this would be part of the input Code: onsubmit="(this.value = this.othervalue)" othervalue being the other input name="othervalue" is that the correct syntax Hi, i have an input value array for customer ids, i also need to make a copy of that array into another input element on submit to use for another process. So far here is what i have come up with regarding the js the current html is this Code: <!-- original input --> <input id="cb<?php echo $i;?>" name="cid[]" value="<?php echo $commissions[$i]['id'];?>" onclick="isChecked(this.checked);" type="checkbox" /> <!-- this is new html input which is outside the $i loop that i need a copy of cid[] stored on submit <input type="hidden" name="ids[]" onsubmit="valueTovalue();" /> <!-- here is the js so far --> <script type="text/javascript"> function valueTovalue() { var valin = document.adminForm.cid.value; //cid is the array cid[] document.adminForm.ids.value = valin; //copy the array to the new input element array ids } </script> so basically if they click 1 cid then ids will also show 1, if they click all cid then ids will show all as well. will that work the way i have it, am i even close here.. thanks update: what i have seems to work fine for text values or string values but not for arrays, what am i missing that it wont copy an array? Array ( [cid] => Array ( [0] => 1 ) [task] => remarksonly [remark] => hhhyyy [boxchecked] => 1 [ids] => Array ( [0] => ) ) am i getting closer lol Code: function valueTovalue() { var valin = cid.concat; document.adminForm.ids.value = valin.concat; return(true); this has to be close i hope Code: document.adminForm.ids.value = [].concat(document.adminForm.cid); 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 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! Hello Everyone, I am trying to set the value of a Input tag with a value retrieved from the cookies. However, it is not working. Here is the script: Code: <html> <head> <title>Example</title> </head> <body> <script type="text/javascript"> document.cookie = "username=John"; var user = get_cookie("username"); document.write ( "Hi " + user + ", welcome to my website!" ); oFormObject.elements["name"].value = user; </script> <center> <br><br><br><br> <form name="register_complaint" action="#"> User Name: <input type="text" size="5" name="name" > <br> <input type="checkbox" name="remeber">Remember Me <br> <input type="button" name="submit" value="Submit Complaint"> </form> </center> <script type="text/javascript"> function get_cookie ( cookie_name ) { var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' ); if ( results ) return ( unescape ( results[2] ) ); else return ""; } </script> </body> </html> Please help me, I've been struggling with this issue for a long time. Cheers How can I ask the user for two different numbers and add them?
How can you get a input box to expand as you type if you exceed X amount of characters?
After searching the web most of the day, nothing has resolved this issue: Code: <!-- ALERT IS NEVER HIT --> <html> <input type="hidden" id="info" name="info" value="testInformation"/> <script type="text/javascript"> var me = document.getElementById('info').value; alert(me); </script> </html> Code: <!-- ALERT SAYS "null" --> <html> <input type="hidden" id="info" name="info" value="testInformation"/> <script type="text/javascript"> var me = document.getElementById('info'); alert(me); </script> </html> Code: <!-- WORKS GREAT, BUT I NEED THE INPUT FIELD HIDDEN --> <html> <input type="text" id="info" name="info" value="testInformation"/> <script type="text/javascript"> var me = document.getElementById('info').value; alert(me); </script> </html> Any idea how I can keep the input value "hidden" and have javascript still see the value? And yes, I've even tried using the "defer" method. I am creating a program that will give you the nutritional value's of the McDonalds menu and I am in need of help to gather the information from the input bar and turn that into a Javascript variable using javascript, the code below is the form, input box, and the case/switch that I would like to use to create this, Thanks in advance! Code: <form id="help"> <input class="sb" id="life" type="text" placeholder="What food would you like to check?"> <button type="submit" class="button">Submit</button> </form> <div id=cci> <script> var item = document.getElementById("help"); var food = item.toLowerCase(); switch (food) { case 'big mac': document.write('<br><br><br>'); document.write('Big Mac'); document.write('<br><br>'); document.write('Calories: 530'); document.write('<br>'); document.write('Carbohydrates (g): 47'); document.write('<br>'); document.write('Total Fat (g): 27'); document.write('<br>'); document.write('Cholesterol (mg): 85'); document.write('<br>'); document.write('Dietary Fiber (g): 3'); document.write('<br>'); document.write('Sugars (g): 9'); document.write('<br>'); document.write('Protein (g): 24'); break; default: document.write('<br><br><br><br>'); document.write(food); document.write('<br><br><br>'); document.write('The food is not recognized'); document.write('<br><br>'); document.write('Double check your spelling'); break; } </script> </div> I am trying but I can't figure it out, let say you select something on your select values, after selecting that value, how can you dynamically put that value on an input box?
Not sure how to describe this. I've been tasked with the responsibility of creating a web form. That's not the problem and I can do that. The trick is, each field needs to be incased in it's own box that flies in from the left. So, the first box that flies in from the left would be email address, when you click enter, it flies off to the right and the next box flies in from the left asking for the persons name. Is it possible to do this and where might I go to learn more about doing this type of coding. Hi, I've devised a javascript to guess what a user is typing in. That all works, but I'm stuck on how to take that value the user has submitted and put it back into the form. At the moment my form is: <form method="post" action="/bin/openathenssp_isapi.dll?type=ukfed&dir=req&requestURL=index.php" onsubmit="send_sso('login_form', 'loading', '<?=SITE_URL?>'); return false;"> <input type='text' name='uni_name' id='uni_name' value='' autocomplete="off"> <input type="hidden" name="entityID" id="entityID" /> //Where the name is guessed <script>actb(document.getElementById("uni_name"),customarray);</script> <input type='submit' name='submit' value='submit'> </form> So basically I'm trying to put uni_name into the entityID. Here's my javascript: function send_sso(ajax_div, loading_div, site_url) { replace_this_div = ajax_div; replace_loading_div = loading_div; var entityID = document.getElementById("entityID").value; if (uni_name == "Bournemouth University"){ document.getElementById('entityID').value = "https://idp.bournemouth.ac.uk/shibboleth"; ...MORE INSTITUTIONS GO HERE... } else { alert("Sorry, the institution '" +uni_name+ "' was not recognised or does not have access to this service."); } } But this does not seem to be working - any ideas? Basically, I have 3 inputs: Code: enter your employee's job position <input type="text" name="position" /> describe the position <textarea name="description" /> enter your employee's initial daily wage <input type="text" name="wage" /> What I want to do is have a button that lets you "add another employee". I was thinking I would have an array for each field and then it could get the values from the text boxes, and add the values to the arrays, however the problem is I need to insert this data into a database at some point. How should I go about this? Hey guys, have a bit of an issue/question... Not sure what I am doing wrong...i do not know javascript at all lol I have a URL stucture which needs to be changed according to the input fields https://sls.example.com/Spc/viewUserProfile.do?source=search&UserId=J-DOE123&vgroupName1=Dealer-jcode-USA-P4038P0122&adminflag=Y This part stays the same at all times https://sls.example.com/Spc/viewUserProfile.do?source=search&UserId= after the "=" sign, I want it to input text from a input box "J-JOE123", so if I put J-DOE123 in the first input box and run the search, I want it to pull up https://sls.example.com/Spc/viewUserProfile.do?source=search&UserId= J-DOE123 after the "J-DOE123", the next part "&vgroupName1=Dealer-" remains the same at all times https://sls.example.com/Spc/viewUserProfile.do?source=search&UserId=J-DOE123 &vgroupName1=Dealer- the next input box would have a drop down with 2 selections (jcode and lcode) so depending on which one is chosen, that is how it would populate the URL https://sls.example.com/Spc/viewUserProfile.do?source=search&UserId=J-DOE123&vgroupName1=Dealer- jcode next, i would need for it to put a "-" after the chosen jcode or lcode in the URL, which will also be there at all times https://sls.example.com/Spc/viewUserProfile.do?source=search&UserId=J-DOE123&vgroupName1=Dealer-jcode - the next input box would have a drop down with 2 selections (USA or CAN) so depending on which one is chosen, that is how it would populate the URL https://sls.example.com/Spc/viewUserProfile.do?source=search&UserId=J-DOE123&vgroupName1=Dealer-jcode- USA next, i would need for it to put a "-" after the chosen jcode or lcode in the URL, which will also be there at all times https://sls.example.com/Spc/viewUserProfile.do?source=search&UserId=J-DOE123&vgroupName1=Dealer-jcode-USA - next, i will have a drop down box containing several hundred codes such as "P0122" and many more. for this, I would need for the display value to be "P0122" but when the URL gets populated, it would have to be "P4038P0122" https://sls.example.com/Spc/viewUserProfile.do?source=search&UserId=J-DOE123&vgroupName1=Dealer-jcode-USA- P4038P0122 The reason why the entire code must change is because P0122 would be P4038P0122, but if it is P0165, it would be N1534P0165, so each code would have its own first part and second part, but in the drop down box, i want it to only display the 2nd part P0122/P0165/etc.. because that is what I go by, but the system only reads full codes. I do have a spreadsheet with the entire list of FULL codes and can do an extract from each cell in order to get the SHORT code. and finally, the URL would have to end with "&adminflag=Y" and will remain the same at all times. https://sls.example.com/Spc/viewUserProfile.do?source=search&UserId=J-DOE123&vgroupName1=Dealer-jcode-USA-P4038P0122 &adminflag=Y So, all together I would have 4 input fields in the form. UserID, jcode/lcode, USA/CAN, and Code. Please help who ever can. If you need more info, please let me know and I shall try my best to explain further. Thanks in advance guys hi, i was wondering if anyone could help me with decoding an input box value and passing that into the url. its been super frurstrating trying to do this. thank you in advance! basically i wrote a function that decodes a url. for example if i enter t05:34:23-79-79.003z.444z, i want it to stay like that when it goes into the url. if you use internet explorer, entering that input becomes... t05%3A34%3A23-79-79.003z.444z. on google chrome, it stays as t05:34:23-79-79.003z.444z but i need this to work on internet explorer. [<html> <head> <script type="text/javascript"> function decode() { var obj = document.getElementById("workorder"); alert(obj); //is it normal that this alert just returns 'object'? am i calling the form wrong somehow? var encoded = obj.value; obj.value = decodeURIComponent(encoded.replace(/\+/g, " ")); } </script> </head> <body> <div id="workorder" style="display: block"> <form name = "workorder" action="http://localhost/Lights/WorkOrder.jsp" onsubmit="return validate_form(this)" method="get"><b>WorkOrder:</b> <br> Id Required: <input type="hidden" name="method" value="getWorkOrders"> <input type="text" name="lightId" size="30"> <input type="submit" onclick="decode()" value="Go"> <br> </form> </div> </body> </html>] thank you advance! how would you make when you press a button it writes somthing in a input box.
I'm guessing this question will be one of the easiest questions ever posted but I'm just not getting this fix. I have a simple Javascript program that calculates a users pace for their run. The inputs are done through an HTML Form. The user can input hours, minutes, & seconds of their run. Then the distance number & measurment. Then finally the pace desired. I am having some trouble with null values in this program. If I input a 0 in hours and then fill everything out the program works great. 100%! But, if I leave the field blank and hit calculate I get a NaN. I'm guessing I need some kind of statement like if this value is null set it to zero but I am not having any luck with exactly what kind of syntax I need. So here is the code, again not very complex, any help would be greatly appreciated! function calculateTime(){ var time_hour = parseInt(document.getElementById("time_hour").value); var time_min = parseInt(document.getElementById("time_minute").value); var time_sec = parseFloat(document.getElementById("time_second").value); var dist_num = parseFloat(document.getElementById("dist_num").value); var pace_choice = document.getElementById("pace_choice").selectedIndex; var dist_choice = document.getElementById("dist_choice").selectedIndex; var total_sec = (time_hour * 3600) + (time_min * 60) + (time_sec); // Then I'm guessing my if statement would go here somewhere? |