JavaScript - Best Way And Easiest For A Beginner To Set Up A Numpad!!!!
Hello,
I was wondering what the easiest and best way for a beginner like myself to set up a keypad with numbers only and have them incorporate it to a text area or box, basically the user will click the button and the number that is pressed will show up in the textarea or text box. I am wondering what the best way to do this is. Code: <input type="image" id="1" src="Button1.gif" alt="Calculator Button #1"/> This is the line of code (an example of it) that I am working with. So my question is what is the best way to do this. Thanks for the help. Similar TutorialsSo, I've designed a basic site and everything is fine except for the posts. You can see the site here. What I'm talking about is this: Code: <div id="posts"> <h1>Bonjour</h1> <p>Welcome to my website! Please note that it's fairly new, and so it might still go under some construction, so don't expect what you see now to be stay the same forever. Furthermore, if you have any suggestions, please run them by me and I'll take them into consideration.</p> <p>As of 9/23: Working on Adding Games.</p> <br> </div> The CSS code for it is: Code: #posts{text-indent:15px;background-color:#424242;border:3px solid #e0e0e0;position:absolute;left:212px;top:180px;width:565px;} Now, the post is only one post, and I can't add any more as it is only one div. I was wondering if there was an easy way to make a master, parent div and all the div's inside it would be transformed into div's that are respectively positioned under it, automatically. ^^ Now, I liked that idea at first but then I thought of the technicalities such as having to use HTML to write blog posts which would be kind of ridiculous and I was wondering if anyone knows how of a simple-free easy to integrate blog system which could be embedded into my site without having to re-design everything. I need a simple handy utility of some sort to test out the scripts while I am studying, any referrals please?
OK so I have a variable called url and I want to move its contents into the form action once the button is submitted. <script type="text/javascript"> function elibrarySearchGo(){ var url = "http://url'" } </script> <form name="searchform" target="_blank" action="" onsubmit=""> I need the syntax as to how to put in a variable coming from javascript inside onsubmit="document.form.action.value = variable" for example. Also, is it better to run this population of the action onsubmit or onclick? Thanks all in advance!! I will start off by saying yes this is homework but I only want help. I'm trying to make the content show up in the read only boxes but I can't figure out where I'm going wrong. My test page can be found at http://sidewalk-cafe.com/test/maddox-hw2a.html. It's small. Any help would be appreciated. Code: function orderForm() { var formDaysStaying = document.getElementById("daysStaying").value; var formSeason = document.getElementById("season").value; var formPropertyType = document.getElementById("propertyType").value; document.getElementById("FEE").value = "$" + today.toFixed(2); document.getElementById("totalCost").value = "$" + today.toFixed(2); document.getElementById("today").value = "$" + today.toFixed(2); document.getElementById("due").value = "$" + due.toFixed(2); } function formTotalCost(form) { const FEE = 55; var totalCost = (formPropertyType * formSeason) * formDaysStaying; var today = totalCost * .10; var due = (totalCost + FEE) - today; if (document.getElementById("daysStaying").value == "" || isNaN(document.getElementById("daysStaying").value)) alert("Please provide the number of days you will be staying."); // Submit the order to the server form.submit(); } I am very new to JavaScript and I am currently following the Eloquent JavaScript book online. On one of the exercises, we are told to make a function that returns the range of the inputs in an array. I tried this code below but it doesn't seem to work. The problem seems to be in the "If" function because if I change the condition to (start < end) it seems to work. Can someone please explain to me why this is? function range (start, end) { var j = []; if (start > end) { for (i = start; i <= end; i++) { j.push(i); } } else { for (i = start; i >= end; i--) { j.push(i); } } return j; } console.log(range(10, 2)); console.log(range(2, 10)); Reply With Quote 01-26-2015, 08:49 PM #2 Labrar View Profile View Forum Posts New Coder Join Date Jun 2008 Posts 65 Thanks 0 Thanked 12 Times in 12 Posts Why you do not use something like this var range = function(start, end, step) { var range = []; var typeofStart = typeof start; var typeofEnd = typeof end; if (step === 0) { throw TypeError("Step cannot be zero."); } if (typeofStart == "undefined" || typeofEnd == "undefined") { throw TypeError("Must pass start and end arguments."); } else if (typeofStart != typeofEnd) { throw TypeError("Start and end arguments must be of same type."); } typeof step == "undefined" && (step = 1); if (end < start) { step = -step; } if (typeofStart == "number") { while (step > 0 ? end >= start : end <= start) { range.push(start); start += step; } } else if (typeofStart == "string") { if (start.length != 1 || end.length != 1) { throw TypeError("Only strings with one character are supported."); } start = start.charCodeAt(0); end = end.charCodeAt(0); while (step > 0 ? end >= start : end <= start) { range.push(String.fromCharCode(start)); start += step; } } else { throw TypeError("Only string and number types are supported"); } return range; } Thats pretty similar to php range Reply With Quote 01-26-2015, 09:25 PM #3 Old Pedant View Profile View Forum Posts Supreme Master coder! Join Date Feb 2009 Posts 28,310 Thanks 82 Thanked 4,754 Times in 4,716 Posts Ignore Labrar's ridiculously complicated answer to a very simple problem. Instead look CAREFULLY at this code: Code: if (start > end) { for (i = start; i <= end; i++) { Let's use your first example, where you call range(10, 2) So start is 10. And end is 2. So you get to if ( start > end ) and JavaScript executes that as if ( 10 > 2 ) Indeed, 10 *IS* greater than 2, yes? SO you the go execute the NEXT line: for (i = start; i <= end; i++) Which, of course, JavaScript then executes as for (i = 10; i <= 2; i++) But then 10 is *IMMEDIATELY* <= 2. So the for loop NEVER RUNS. All you need to do to fix your code is change Code: if (start > end) { into Code: if (start < end) { PRESTO! ********** The tiniest bit of debugging using your JavaScript debugger would have found this. But also just learning to THINK like the computer would help. Actually run the code in your head, using your example numbers, and you'd see where you went wrong. Hi there, im wondering if you can help me i need help in finding javascript resources to build my skills and knowledge of Jscript because im a beginner. Please help hello! i have a problem: i want to change the height of my side bar as long as the text in the center of page long, it means when I have for ex 3 news in a page the side bar which have a background color must be increase to fit the long of text(3 news). i think it will do by javascript but i'm not sure! i my question isn't clear please tell me to explane more i really need it, Hi every one I'm a beginner to java so I have a home work assignment and I'm suppose to create a soda machine thing. What I'm trying to do is make the price of soda * quantity of soda which will equal to the price with tax but I cant figure it out @_@. I know what I'm doing wrong with the "Total" button and the "value" and "quantity" and I've been looking over the internet and playing with it like crazy. So if anyone can help me figure this out that would be great. The code and a pic is on the bottom i hope i gave you guys enough info. This is what im trying to do. Hi all, this is my first attempt at JavaScript code. I'm trying to write code for an Adobe Acrobat form. Here is my situation: I have several boxes, all containing numbers such as 2014, 08, and 000000000. I want to concatenate them all into one long number like 080000000002014. I've looked at a ton of sample code, but nothing I try seems to work. Any help is greatly appreciated.
Hi people I'm hoping someone can help me. I have NO knowledge of Javascript but I'm not afraid of code and happy to look at it and work out what is doing what. I need someone to provide me with a small sample of code to get me started on this task. I need a webpage with a number of drop down menus. Depending on what the user selects in these menus, depends on what sentence or paragraph is then displayed in a box. For example you might have a page dedicated to food. So the user would select egg in the first drop down and the box will change to display "you can't make much with that on it's own".# You'll then select flower in the second and it'll adjust to a paragraph maybe explaining where you could go next with that. In my page I need 6 drop down menus with about 8 choices in each menu (nothing related to food). Not sure if I would need to tie this in with a database or if I could just make do with the code on the page. As I said I'm hoping someone can just kick me off with something do I can get a rough idea of how I would go about coding it. Maybe an example contain 3 drop down menus with 2 choices on each and a few possible sentences or paragraphs that it could generate in a box. If not then any advice would be really appreciated as I said I'm a complete newbie and I've never even looked at Javascript code to my knowledge. Many thanks I'm trying to get this simple (not to me) ascii animation going and firebug is giving me an error saying "document.getElementById("frameArea") is null. I've got an element named frameArea and I wonder if it's buried too deep. I don't really understand this code which I admit is a big part of my problem. I have seen what it is supposed to do, which is play a simple animation. Will someone please help me decipher what this code is saying? Code: <html> <head> <title>Animation</title> <script type="text/javaScript"> function playAnimation() { frameStr = document.getElementById("frameArea").value; if(frameStr.indexOf("\r\n") != -1) { frameSeq = frameStr.split("=====\r\n"); } else { frameSeq = frameStr.split("=====\n"); } currentFrame = 0; showNextFrame(); } function showNextFrame() { document.getElementById("displayArea").value = frameSeq[currentFrame]; currentFrame = (currentFrame+1)% frameSeq.length; timer = setTimeout("showNextFrame();", 250); } </script> </head> <body> <div style="text-align:left"> <h1>My Animation</h1> <hr /> <form name="animationForm"> <table> <tr><td align="center"><b>Enter frames below separated by "====="</b> <td> <td align="center"> <tr><td><textarea name="frameArea" rows=12 cols=35 wrap="virtual"></textarea> </td> <td align="center"> <br /> <input type="button" value="Play --->" onclick="playAnimation()"> </td> <td><textarea name="displayArea" rows=12 cols=35 wrap="virtual"></textarea> </td> </tr> </table> </form> </div> </body> </html> Hey guys, Thanks for taking the time to read my post. I am not new to programming or scripting, but I am completely new to javascript and web-based code. Hopefully you guys could help me understand what is going on and maybe help me figure out what I am trying to do. What I am trying to do: -There is an element that has a value <td class="flashField" onmouseover="clearAnswer()"> <div id="flashAnswer" onmouseover="clearAnswer()">answer string here</div> </td> -There is a text box that needs to have the answer above given to it <td class="flashField"> <input type="text" tabindex="1" onkeypress="clearAnswer()" name="q" maxlength="256" size="50"> </td> -There is a next button that needs to be executed <td align="right"> <input type="image" tabindex="2" alt="Next" src="http://website.com/images/next.gif"> </td> So what I am trying to do is create a script through Greasemonkey that will automatically do these things. I am starting small and trying to just get the value of flashAnswer to appear as an alert on the screen by using this code: var answer = document.getElementById('flashAnswer'); alert(answer); But the problem is it posts some weird value ([object XrayWrapper [object HTMLDivElement]]) that most definitely is not "answer string here" and is a bit above me at this point. Any ideas? Any help would be great guys! Thanks! -ellosiph I just started to learn javascript. can someone please tell me why my script below does not work? Is it not how it should be done? <html> <head> <title> Javascript Navigation </title> <script type="text/javascript"> if(yahoo.onclick()==true) { window.location = 'http://www.yahoo.com'; } </script> </head> <body> <form> <input type="button" name="yahoo" value="Click Here to go Yahoo.com"/> </form> </body> </html> is this code right its supposed to be a code that prompts the user for a number less than 100 and outputs only odd numbers less than or equal to the number entered by the user.for example if a user eneters the number 10 you should display 1,3,5,7,9 to the browser window?...im not sure if i have done it right..i gave it a go though! var input = prompt("Enter a number less than 100:", "10"); if( input <= 100){ nbsp; for (var i = 1, i <= input, i++2){ nbsp; document.write(i", "); nbsp; } }else{ nbsp; alert(input + " is not less than 100!"); } 3 questions. I am very very new to JS (i am a html/css wiz but am just now learning js. I have taken 2 university CS courses but both were with C++)... My friend sent me these problems and wanted some help. Anyone here wanna give em a go? Given the string "Frank delete from users Beans" in a textfield If you find any sql token you find (like delete, drop, truncate, etc), strip it out, and regenerate the original string without those tokens; place the regenerated string (without the sql) back in the textfield. If You cannot strip out the sql and place the sanitized value back in the textfield, you will not get full credit for this question. Write a document that contains 5 paragraphs, and 4 headers. Create a script that finds all of them and puts "FOUND IT" beside it. Create a document that lets user's enter a planet's (like Jupiter, Saturn, Mars...) name (via a select or input field), and at the click of a button (or when the selected option was chosen), have the distance (from the Sun or Earth) appear next to that select box or textfield (which ever you choose to implement for the input from the user.) Please use Google to find the distances. HINT: use innerHTML = '...' Thanks guys! Hey guys, I've come here looking for a little help. Probably for a very easy problem to you guys lol. I have a script (this is just a snippet of it): Code: $("#wgo_onlineusers_list").find(":contains('Username')").closest("li").addClass("isOMM"); It basically finds the Username value using the online user list and adds them to a separate special "currently online" list at a different spot on the homepage of the forum. My problem is that if I have a simple username, for example "Big", it adds all usernames with "Big" in it. I know all I need to do is change it so that it catches only the exact username, but I'm having trouble finding a selector (if there is one) that can do this or if it'll be a little more work to fix. Is there any simple fix that is right in front of my eyes for this or do I need to rewrite the function completely? I'm sort of just getting into JS/jQuery and this forum looks like it will be incredibly helpful for me in the future cus of it's activity. Reply With Quote 01-30-2015, 05:17 AM #2 Old Pedant View Profile View Forum Posts Supreme Master coder! Join Date Feb 2009 Posts 28,310 Thanks 82 Thanked 4,754 Times in 4,716 Posts You really need to ask this in the jQuery forum. But I'm with you: I don't see anything in the jQuery docs that supports "equals" instead of "contains" for text values. Hey guys, I am working on building a new site and was wondering if I could get some clarity on something with JS, as I am el noobo. I have the basic layout he http://www.temp3.hangnailproductions.com/ Now this is just a mock up and I plan to validate the code, make it more semantic and clean up my CSS quite a bit, but right now I just want to get an idea of what I have to do and something has caught my eye. When the page loads, it takes quite a few seconds for the javascript I have attached to populate a few areas on the screen. At the top of the page there is a random testimonial and the current date. Both are populated from this script: http://www.temp3.hangnailproductions.com/js/master.js I don't know if these areas take a few seconds because my code is horribly wrong, too large, or if this is just normal. Does the array that holds the testimonials hold too much information? I would really appreciate some help. Also, the section that says "This should be a small blurb about the link above." is going to be a snippet of text that changes when a user mouseovers a main link at the top. I think this will also be JS and included in the same "master.js" file - thoughts? Thanks very much. (And I know it is ironic that I am asking for help on a site that sells web design, but Javascript is not something I plan to push, and if need be I would hire someone to help with any in-depth JS. I thought this would just be a simple little project...) Hi there! Here's my problems: The problem 1 is about making triangle with "*", but i must not use <center> so the triangle must be on the left side.. Here's my code: var x = parseInt(prompt("Your value","")); var A= ""; var B=[" "]; for (i=0; i<x; i++) B[i+1]=B[i]+" "; for (i=0; i<x; i++) { A = A+"*"; document.write("<br>" + B[x-i] + A) } How can i make this code more basic? The problem 2 is about taking random different elements from Array. Here's code: var items = Array(0,1,2,3,4,5,6,7,8,9), a; document.write("Secilen elemanlar: "); for (i=0; i<5; i++) { a= Math.floor(Math.random()*items.length); document.write(items[a]); items.splice(a,1); } In that problem how can i do the same thing without splice. And the problem 3 is about number triangle like this 1 232 34543 I couldn't write any code,and cane you give some advices like "what methods i must use"? Reply With Quote 02-04-2015, 07:34 PM #2 felgall View Profile View Forum Posts Visit Homepage Master Coder Join Date Sep 2005 Location Sydney, Australia Posts 6,745 Thanks 0 Thanked 666 Times in 655 Posts splice is about the only command there that you should consider using. Yuo are misusing parseInt() where you should be using Number() and the prompt() and document.write() should never be used at all - they became obsolete many years ago. var suitArray = ["Hearts","Diamonds","Clubs","Spades"]; var faceArray = ["Ace", - Pastebin.com Doing a school assignment and Im totally stumped, google isnt any help nor is any of these textbooks. I need to tally up the playerhands and dealer hands and display the winner. I can get it to display the value of the current card. eg 7 of diamonds = 7 points but I cannot get it to tally up all the cards dealt. hi folks extreme newbie here when it comes to javascript. I have an assignment that in which ive created the html+css for the webpage (a pizza form validation basically). and Now I must do the javascript aspect of it. Unfortunately I have no idea how to even begin i dont understand how to use any of these .toUpperCase() .toLowerCase(), how to use window.open for errors instead of alert and all these other things. the way i'm coding it, is with an external file called script.js that will have all my coding and then i have my index.html file...i dont know how to 'call' (if thats the right term) the function to the index.html...or even make jscript code either lol. as an example of a requirement: Code: field01 - Client Surname- Maximum allowable length is 15 positions Must be present. Minimum of four (4) alphabetic characters lower case (a-z) or upper case (A-Z) or a mix of lower & upper case. Optional special characters Optional one (1) apostrophe if present - must have at least 1 alphabetic character before it and one alphabetic character after it. Optional one (1) hyphen if present - must have at least 1 alphabetic character before it and one alphabetic character after it. this is my assignment requirements for those need a better understanding of what's going on https://cs.senecac.on.ca/~int222/***...assignment3-2/ my request is if there is anyone who can lead me in the direction to a website or downloadable book on how to do what it's asking (in no way am i asking someone to do my assignment for me). My professor has his website that has all these predefined things (im assuming are functions) that should be used but i dont understand it nor do i understand him. Any help would be immensely appreciated, thank you. |