JavaScript - Coding Question
ok im new to coding and was woundering is there a way to open up a game through a program that could have an attached macro or anything..
like for example i would have a racing game that u need to shift and i open it with the coded program and it shifts like an automatic. i sorry if its in the wrong section . thanks Similar TutorialsHello, This is my second post on the forum and I am a coding beginner and therefore relatively new to the forum so sorry for any naive ignorance in the questions I may ask. I was wondering if anyone could please pass their assisstance regarding a functioning question...? I am completely stuck and cannot get my head around it on which methods are necessary?! For this question I think I have to follow the specification pretty regimently, eg. the example result has to include the double quotes around 'prog found in pages 0,3,5,6,9'. v) function findIdxsC(s) - to return a string containing the indexes in the pages array where s was found in the content part, e.g. "prog found in pages 0,3,5,6,9" [Note that this function will not contain an alert] Example call: findIdxsC("prog") Example result: "prog found in pages 0,3,5,6,9" Cheers, George Hi, I'm still in the early stages of learning Javascript so I'm not sure how (or if it's possible) to do this. I know HTML, CSS, etc... just not too familiar with Javascript. Here's the deal.... I run a website that features a chat room written in Perl for CGI. The chat room will automatically email a user their password if it's forgotten but there is one issue.....it does not have the "Forgot Password?" link. To achieve the Lost Password page, the user must enter an invalid password FIRST on the login screen, otherwise they cannot get to that option and are often requesting assistance. What I had in mind was an easier way for the user to get their password since new novice members are not sure how to get to the lost password page. I'm not trying to edit the Perl code for the chat, but I wanted to build a "Forgot Password?" page using a Javascript code that will automatically take their username from the "username" login field and direct them to the lost password page which would be "chat2.cgi?action=send_pwd&name=..." I'm sorry if this is confusing, I'm not sure that I am explaining this right. When the user enters an invalid password, it takes them to the lost password page which contains a link "lost password" and will automatically email them their login details when clicked on. When they click that link, the URL contains the string "chat2.cgi?action=send_pwd&name=username" What I would like to do is put a link on the login page (like most normal chat rooms have) that says "Forgot Password?". When clicked on, I want it to take them to a page where all they have to do is enter their username in a form and click Submit, then have a Javascript code automatically extract their username from that field and insert their username automatically to the end of that URL (chat2.cgi?action=send_pwd&name=...) where ... would be the name extracted from that form field. This would result in the browser taking them to that URL which would trigger the chat to automatically email the password. Can I do this with Javascript?? If so, any help would be greatly appreciated! I'm looking to use some simple JavaScript code on a message board when I'm posting a reply to a thread. I believe there was some kind of namescript or namespace in JavaScript that would take the username of whoever opened the thread and place it in my post. So for example, if I said in a thread, "Welcome to my thread, [namescript]" it would place your board handle in the [namescript] function. Any of this sound familiar to anyone and they could possibly point me in the right direction for what I'm looking for? The code below is part of a working program which inserts "tentpay" and date paid. I'm trying to add the code which is below the comment line(//*). It does nothing? can someone look at it? Code: function calculate_paid(v) { var rentdue = document.getElementById("rentdue"); var prevbal = document.getElementById("prevbal"); var misc = document.getElementById("misc"); var late = document.getElementById("late"); var amtpaid = document.getElementById("amtpaid"); var tentpay = document.getElementById("tentpay"); var hudpay = document.getElementById("hudpay"); var datepaid = document.getElementById("datepaid"); var late = document.getElementById("late"); var dateNow = new Date(); var dayNow = dateNow.getDate(); var datePaid = (dateNow.getMonth()+1)+"/"+dateNow.getDate()+"/"+dateNow.getFullYear(); switch(v) { case amtpaid: var tpay = amtpaid.value - hudpay.value; if(tpay >= 0){tentpay.value = tpay;} if(amtpaid.value > 0){datepaid.value = datePaid;} break; case tentpay: if(!hudpay.value || hudpay.value == " "){hudpay.value = 0;} if(!tentpay.value || tentpay.value == " "){tentpay.value = 0;tentpay.select();} amtpaid.value = parseInt(tentpay.value) + parseInt(hudpay.value); if(tentpay.value > 0){datepaid.value = datePaid;} break; case hudpay: if(!tentpay.value || tentpay.value == " "){tentpay.value = 0;} if(!hudpay.value || hudpay.value == " "){hudpay.value = 0;hudpay.select();} amtpaid.value = parseInt(tentpay.value) + parseInt(hudpay.value); if(hudpay.value > 0){datepaid.value = datePaid;} break; //* case prevbal: var balance = parseInt(rentdue.value) + parseInt(prevbal.value) + parseInt(misc.value) - parseInt(hudpay.value); if(amtpaid.value < balance.value){ prevbal.value = parseInt(balance.value) - parseInt(amtpaid.value);} if(dayNow.value > 5){late.value = "L"; prevbal.value = prevbal.value + 10;} break; } } I found this code online to create a like/send buttons for Facebook to put under my posts on my website. When the user clicks "Like" or "Send" I want the content tags from the website to be automatically input into the user's Facebook post: so the Facebook plug-in/post function will attach the picture and link to the site, and have the tags (already associated with the picture within my site's coding) automatically entered as text into the post. I'm not a programmer and thought this might be a good place to get some help. Does something like this already exist that can be altered/edited? I am not familiar with this, and I'm having difficulty trying to explain it. Here is the code I have so far. <!-- Facebook Like+Send script Start --> <b:if cond="data:post.isFirstPost"> <div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) {return;} js = d.createElement(s); js.id = id; js.src = "http://connect.facebook.net/en_US/all.js#xfbml=1"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk')); </script> </b:if> <!-- Facebook Like+Send script End --> <!-- Facebook Like+Send button Start --> <div style='float:left;padding:5px 5px 5px 0;'> <fb:like expr:href='data:post.url' font='' layout='standard' send='true' show_faces='false' width='450' colorscheme='light'></fb:like> </div> <!-- Facebook Like+Send button End --> hi all, i have tried some coding. it only works partly. the alert message box doesn't display. i am not sure of the error. pls help. <html> <head> <title> my firs web page </title> <script language="javascript"> function abc(){ alert("welcome"); } </script> </head> <body> <script language="javascript"> document.write("<h1 align=center> hesitation kills</h1>"); </script> <form name="form1"> enter your name:<input type="text" name="val"> <input type="button" name="submit" value="display" onlick="abc()"> <input type="button" name="color" value=" GREEN " onclick="document.bgColor='green'"> </form> </body> </html> thanks, breentha A short summary of what I'm trying to do is this: I manually charge credit cards for my bosses online business. Doing this requires me to manually enter information in from his websites back office in to a different browser, using "Navigate, Merchant Plus" (that's a site used for banking etc. and allows you to charge cards through it). I'll be the first to admit I know nothing about coding, and I was just doodling with it trying to see if there's a way to automate this. If I can get the code, I can give it to my boss and he can enter it into the website and have a button you can press to transfer the information out of the fields required to charge the card on to the navigate websites fields where you place the information. A sample of the code off of his website - one of the fields that needs to be transferred is this: <td class="main"><input name="update_info_cc_expires" size="4" value="0412" onChange="updateOrdersField('cc_expires', encodeURIComponent(this.value))"></td> The field it would need to go in to on the navigate is this: <tr> <td align="right" valign="top" width="43%">CVV Code:</td> <td align="left" valign="top"><input type="text" id="x_Card_Code" name="x_Card_Code" size="8" maxlength="6" /></td> </tr> ___________________________________________ So I'm unsure if this is the code needed to do what I'm talking about doing, but hopefully I've grabbed enough of the code for some pro to work with. If someone can tell me how to transfer just that one field in to the other, then I could apply it to the rest of the fields and save my boss the time on doing it, and make it a lot easier and less time consuming for me at work while I'm at it. Thanks and get back to me soon! I really appreciate anyone that takes the time to try to help. Let me know if I need to grab more code than what I did. Okay, I'm actually just starting out Javascript so I thought you guys could hopefully help me with a bit of a newb question. I'm trying to start a comic website, and in the process of trying to make the "Previous" and "Next" buttons. Code: <div id="content"> <div id="control"> <div id="prev" style="cursor:pointer" onclick="changeComic()"> <h5>previous</h5> </div> <div id="next" style="cursor:pointer" onclick="comicChange()"> <h5>next</h5> </div> </div> <img id="comic" src="/images/comics/page005.png" alt="there is no alt"> </div> I'm not sure what the Javascript should be really. What I want is, everytime someone clicks the "Previous" button, the src of the img should change from 005 to 004, basically it's just subtracting a "1" from the img src, and the "Next" button does the opposite and adds a "1" to the img src. I had it working at school but im messing something up here, pretty much whats supposed to happen is I have a page full ofpictures, and when I hover over 1 all of them are supposed to go transparent except for the image highlighted, can anyone point out whats wrong? Also im using mozilla, i dont understand whats wrong, its something with the for statement because the function itself is working as it should. Code: function into(whoseCalling) { document.getElementById(whoseCalling).style.borderStyle = "double"; document.getElementById(whoseCalling).style.borderTopColor = "blue"; document.getElementById(whoseCalling).style.borderBottomColor = "red"; document.getElementById(whoseCalling).style.borderLeftColor = "yellow"; document.getElementById(whoseCalling).style.borderRightColor = "green"; document.getElementById(whoseCalling).style.borderWidth = "8px"; for (i=0; i<30; i++) { document.getElementById("img" +i).style.opacity = ".5"; } } Hey, I am new to coding. I'm learning Java, but I'm wondering if that's the first language I should learn, or should I study something else first. Any help would be very appreciated. I would like to learn how to make software programs, design websites, and hopefully develop video games.
Right I have written some code very similar to this, and then found the similar code somewhere else, and what I want to do, is to be able to call a couple of different scripts into the one script, I have been at this since 9am uk time and I am bashing my head against a brick wall. Code: <script type="text/javascript"> function Msg1(){ document.getElementById('myText').innerHTML = '<script src="page1.js" type="text/javascript"></script>'; } function Msg2(){ document.getElementById('myText').innerHTML = '<script src="page2.js" type="text/javascript"></script>'; } </script> <input type="button" onclick="Msg1()" value="Show Message 1" /> <input type="button" onclick="Msg2()" value="Show Message 2" /> <p id="myText"></p> As a personal note, I have asperger (a form of Autism) and ADHD, and I cant sleep until I can either get this to work, or someone who has more of an idea what I am trying to do tells me your not going to get it work, any help will be appreciated In my javascript code I have to type in a number in a textbox then click a button. When the button is pressed a popup message will come up displaying the number I typed in the text box. I have no clue how to do it, could someone give me an example? Thanks. P.S. I can't use a prompt. if i wanted to create a code that takes the value of a textbox, multipliy it by itself what would i try to do?
I need a script able to find and store a piece of text from my webpages and place it between the code of my links. The piece of text is the user name and is inside a DIV Element. I'll include an example of both the DIV Element and the link to see who can give me some help coding this or at least tell me the tags I should use. The DIV element looks like this: <div>Hi User Name,</div> The link looks like this: <a href="http://www.xxxxxxx.com/click-xxxxxxx-xxxxxxxx">Link</a> I need the following as a result using Javascript: <a href="http://www.xxxxxxx.com/click-xxxxxxx-xxxxxxxx?sid=User+Name">Link</a> Ok so i want to code something like this http://i45.tinypic.com/29y10s1.png I want it to where the user just clicks on one of the buttons and it changes to the thing. But then i want to be where if the user doesn't click anything then it just changes by itself. so like on a timer. Can anyone give me some references that might help me get started with coding this. I have no clue where tos tart. I am wanting a script to find and replace numbers in text it is not working for me so will someone help? I believe that this will work. Code: findAndReplace('(1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59|60|61|62|63|64|65|66|67|68|69|70|71|72|73|74|75|76|77|78|79|80|81|82|83|84|85|86|87|88|89|90|91|92|93|94|95|96|97|98)', '(d)'); However, I need the variable a to equal whatever number it finds. (e.g. 27 --> a=27) I have no idea on how to do that These are theformulas that i need it to do Code: var a = _____ var b = 100 - a var c = 17932 % b var d = a + c I took a codeacademy course that had me program a basic search tool. I thought to attempt to fix the obvious major faults in the search code as sort of a self-evaluation of progress. The faults we 1: Similar names(used as an example search query) of similar lengths are also picked up by the search engine. 2: Only one text box can be searched for the desired word. I thought to fix this, and came up with the following code. I can't figure out why it isn't working, can anyone help me understand? Also, would there be a way to add an if loop to the two long if statements so that this code would work with any length name, instead of having to be rewritten for each name of different length? -JS- /*jshint multistr:true */ text = "Within this block of text this program is designed to pick out only my name, Jacob, and avoid selecting the similar strings of jacob, Jason, and James, leaving only instances of my name, Jacob within both this block of text and the following contained in the text block within var searchText."; var searchText = "Within this block of text this program is designed to pick out only my name, Jacob, and avoid selecting the similar strings of jacob, Jason, and James, leaving only instances of my name, Jacob within both this block of text and the one preceding contained in the text block above. Jacob Jacob"; var myName = "Jacob"; var hits = []; var hits2 = []; var hL = (hits.length) var hL2 = (hits2.length) for(var i = 0; i < text.length; i++) {if(text[i] === myName[0]) {for(var j = i; j < (myName.length + i); j++) {if(text[j] === myName[j - i]){hits2.push(text[j]);} } } } for(var i = 0; i < searchText.length; i++) {if(searchText[i] === myName[0]) {for(var j = i; j < (myName.length + i); j++) {if(searchText[j] === myName[j - i]){hits.push(searchText[j]);} } } } if (for(var k = 0; k < hits.length; k++) {if((k mod myName.length) === 0 && hits[k] !== hits[k mod myName.length]){hits[k] = "0"} else if((k mod myName.length) === 1 && hits[k] !== hits[k mod myName.length]){hits[k] = "0"} else if((k mod myName.length) === 2 && hits[k] !== hits[k mod myName.length]){hits[k] = "0"} else if((k mod myName.length) === 3 && hits[k] !== hits[k mod myName.length]){hits[k] = "0"} else ((k mod myName.length) === 4 && hits[k] !== hits[k mod myName.length]){hits[k] = "0"} } for(var z = hits.length - 1; z >= 0; z--) { if(array[z] === 0) { array.splice(z, 1); } } if (for(var l = 0; l < hits2.length; l++) {if((l mod myName.length) === 0 && hits2[l] !== hits2[l mod myName.length]){hits2[l] = "0"} else if((l mod myName.length) === 1 && hits2[l] !== hits2[l mod myName.length]){hits2[l] = "0"} else if((l mod myName.length) === 2 && hits2[l] !== hits2[l mod myName.length]){hits2[l] = "0"} else if((l mod myName.length) === 3 && hits2[l] !== hits2[l mod myName.length]){hits2[l] = "0"} else ((l mod myName.length) === 4 && hits2[l] !== hits2[l mod myName.length]){hits2[l] = "0"} } for(var y = hits.length - 1; y >= 0; y--) { if(array[y] === 0) { array.splice(y, 1); } } if (hits.length === 0) {Console.log("Your name wasn't found!");} else {console.log(hits); } if (hits2.length === 0) {Console.log("Your name wasn't found!");} else {console.log(hits); } Hey, I'm try to create a web page which slides down sub catagories when menus are clicked on. However, when the divs slide down there seems to be an unwanted 'snap' in the movement. Does anyone know how to solve this? Also, when the menu headings are clicked on the second time (which should slide the menu back up), the menu title disapears?? Heres the coding I've used and the link to the site: http://www.pumphouseapps.co.uk/graph...ents_page.html <script type="text/javascript"> $(document).ready(function() { var SectionName; var SectionNameLengh; var sectionChildName; var childName; $(".Subsection01").toggle( function () { SectionName=this.id; $("#"+SectionName).children().each( function() { var child = $(this); if (!(child.hasClass('MainSectionTitle'))) { child.slideDown(); } } ); /*$(".Subsection02").slideDown();*/ /*SectionNameLengh=this.id.length; sectionChildName= SectionName.slice(0,SectionNameLengh-4); $("#"+sectionChildName).show();*/ }, function () { SectionName=this.id; $("#"+SectionName).children().each( function() { var child = $(this); if (!(child.hasClass('MainSectionTitle'))) { child.slideUp(); } } ); /*$(".Subsection02").slideDown();*/ /* SectionName=this.id; SectionNameLengh=this.id.length; sectionChildName= SectionName.slice(0,SectionNameLengh-4); $("#"+sectionChildName).hide();*/ } ); $(".Subsection03").toggle( function () { SectionName=this.id; $("#"+SectionName).children().slideDown(); /* SectionName=this.id; SectionNameLengh=this.id.length; sectionChildName= SectionName.slice(0,SectionNameLengh-4); $("#"+sectionChildName).show();*/ }, function () { SectionName=this.id; $("#"+SectionName).slideUp(); /*SectionName=this.id; SectionNameLengh=this.id.length; sectionChildName= SectionName.slice(0,SectionNameLengh-4); $("#"+sectionChildName).hide();*/ } ); }); </script> I am trying to build a simple test/questionnaire where the user inputs answers into a form. These answered are then checked with stored data in arrarys to see if they are correct or not. At the end the score is totaled and given to the user PROBLEM im confused at to how to structure the code and also am aware that i am missing several coding functions ect e.g. i know that i need to use 'getelementbyid' somewhere. ANY HELP WOULD BE APPRECIATED, THANK YOU CODE Code: <html> <script language="text/JavaScript"> function checkanswer() { if (q1==answer[0]) { alert('Right well done u got it correct') } else { alert ('unlucky you got it wrong') } answer = new Arrary(); answer[0] = "blue"; answer[1] = "green"; answer[2] = "red"; </script> <body> <form action="qform"> question 1: <input type="text" id="q1" value="" /> <br /> question 2: <input type="text" id="q2" value="" /> <br /> question 3: <input type="text" id="q3" value="" /> <br /> <input type="submit" value="submit" /> </form> </body> </html> |