Search the Community
Showing results for tags 'javascript'.
-
i learnt java and c++ a few years ago but stuck oop, i never made a gui application for example, i tried some people's project, when i ran it into my netbeans, there were so many errors, but i want to learn javascript right now, i think i am able to run it in console / command prompt but seriously, why does the syntax look so different when it comes to oop / gui application. where i can a fully guide e-book for idiot like me ? (i read javascript for dummies e-book, but i couldnt find oop examples) thank you
-
No matter how I try I can't get the single digit dates to match with statements, if's or anything else. var jsDate = new Date(arrayJson["Date"]); var jsDate = jsDate.getDay(); alert("Looking for day: " + jsDate); switch(jsDate){ case "6": // Saturday jsDate.setDate(jsDate.getDate() + 2); alert("Saturday"); break; case "0": // Sunday jsDate.setDate(jsDate.getDate() + 1); alert("Sunday"); break; case "1": // alert("Monday"); break; case "2": // alert("Tuesday"); break; case "3": // alert("Wednesday"); break; case "4": // alert("Thursday"); break; case "5": // alert("Friday"); break; default: alert("Default"); } alert("Date is: " + jsDate.toLocaleDateString("en-GB")); I've gotta have missed something simple and privative. Alerts work fine and I can tell what I'm looking for, just the cases and if's never match, as if the single digit number isn't a single digit nor a string or int that can be matched against, just always goes into default case.
-
Run into a problem where I need a function that is outside the document.ready to call a function that is inside it. $(document).ready(function () { function ExampleDoStuff(var message){ alert(message); } }); function CalledExternally(){ ExampleDoStuff("Do Stuff"); } Ideally I'd have everything inside the ready script but I need the other function to be called by a different JS file, that also exists on the browser page, I couldn't call it if it was inside the scope of ready but could if it was outside. I can think of two fixes: How can I place CalledExternally inside the ready and for it to be easily called by different JS files without the files explicitly referencing THIS file? If not, how can I get the code above to work. Online says to make the ready an class, doesn't work so I guess I keep doing it wrong?
-
I take in json data that I want to go through and use the fields that I need. Data looks like this { "Part1": { "Field_1": { "Type": "", "Name": "", "special": "" }, "Field_2": { "Type": "", "Name": "", "special": "" }, "Field_3": { "Type": "", "Name": "", "special": "" }, "Field_4": { "Type": "", "Name": "", "special": "" }, "Field_5": { "Type": "", "Name": "", "special": "" }, "Field_6": { "Type": "", "Name": "", "special": "" }, "Field_7": { "Type": "radio", "Name": "RadioDefault", "special": "for" }, "Field_8": { "Type": "radio", "Name": "RadioDefault", "special": "for" }, "Field_9": { "Type": "radio", "Name": "RadioDefault", "special": "for" } }, "Part2": { "Field_1": { "Type": "", "Name": "", "special": "" }, "Field_2": { "Type": "", "Name": "", "special": "" }, "Field_3": { "Type": "", "Name": "TargetID38", "special": "rows=\"2\"" }, "Field_4": { "Type": "", "Name": "", "special": "" }, "Field_5": { "Type": "", "Name": "", "special": "" }, "Field_6": { "Type": "", "Name": "", "special": "" } } } I've parsed the whole json into an object certElementData = Object.entries(JSON.parse(result)); And tried to loop through the data. Getting unlucky here. Maybe I should go back to simple for loops but I want to try out the for in and for of loops. For of loops do well until I get to the Field_'s part as that refuses to go into a array and stays being an object. If I try to use a for in loop, that loop will wipe any following data, saying that sure it'll now loop through to Field_9 but that's it, there's no data after it. How can I retain all the data yet get to the bottom info such as "Name":"" and "Type":"" that I need. Have a look at the initial start parse as well. What if I'm needlessly parsing them and made a mistake at the start? Thanks.
-
Got a simple field <label for="comment">Text here</label> <textarea class="form-control" rows="2" id="comment" name="ID1"></textarea> and I want to get label text. I can easily get the field value with elementByID as well as jQuery .val() but no luck getting to the label and the text that is in there. In theory should be pretty simple, I've gotta be forgetting something.
-
Delete this before posting. Please make sure to include the language that you're using in the title, and use the <> button for any code. I have a modular table, its size depending on the array that makes it. Its ID would look something like "AA[0][1][A]" Haven't found anything that I can pinpoint at but it seems like jQuery doesn't like arrayed ID's. My normal ID's work when jQuering like alert($("#I001").val()); but the moment try to do it in the form of my array ID it's a dud. I've tried alert($("#AA[0][1][A]").val()); As well as var IDValue = "AA[0][1][A]"; alert($("#" + IDValue).val()); And still nothing. Everything always comes back as "undefined." Feels like an amateurish mistake but it's hooked me and I can't let go. I need to know why my jQuery isn't working, well the array ID at least, normal ID is fine.
-
To keep code simple and scalable, I'm hoping there's a way to list multiple classes inside jQuery events. I've got 3 inputs I want to have code listen to. I've tried: $('.table_1','.table_2','.table_3').on('focusout', function () { // alert("multi on focusout"); }); and $('.table_1 .table_2 .table_3').on('focusout', function () { // alert("multi on focusout"); }); I feel like I'm close and this is the way it's meant to work in functionality, I just don't have the proper identifiers to let jQuery know I'm listing multiple classes into one event. What is the correct way of identifying this?
-
So I have a form, using some radio buttons for mutually exclusive selection. Radio buttons are great as I can simplify code (basically not write any code for it) as they do exclusivity automatically. All is great except field serialization. I send off my form data, it saves the radio fields under a single name by which they are all grouped under, I can't give each a unique name otherwise their radio function stops working. Problem is, if I have 3 choices the only serialized data might be: "flexRadioDefault":"1" ...good luck me finding out which one of the 3 was selected. My only brainstorm solution is to actually send off the button ID inside the "value" which I could reference later? Instead of "1" here could be "flexRadioDefault":"ID1 to 3." For documentation and form loading. What would be the best way to sort this out? Am I good to try and figure out how to cross reference which radio button was selected with sending the ID inside value or am I overcomplicating things not aware that there's an easy solution?
- 5 replies
-
- html
- javascript
-
(and 2 more)
Tagged with:
-
I'm going to study 2 year in programming and I'm unsure what to choose. The educations I'm choosing between are one called "Front End Developer" and "Cloud Developer (Azure)". Azure are more popular in my country than AWS since most companies are centered around the Microsoft products; AD, AAD, Office 365 according to a consultant. Here's the courses in the included in these two educations: Cloud Developer (Azure) course content: Basic Concepts in Object-Oriented Programming Programming Language C# & Visual Studio Object-Oriented Analysis & Modeling with UML APIs and their structure The .NET Platform & .NET Core Application Development in C# .NET HTML5, CSS3 & Fundamentals of JavaScript Frameworks (React/Angular) & Web Security Azure Platform and Portal & Azure App Services Automating Azure with Azure CLI Cloud Databases & Cloud Storage Development Models: Waterfall, Agile, DevOps ASP.NET Core & Service Fabric Front End Developer course content: Web Development: Frontend Basic JavaScript Programming Web Communication User Experience and Interaction Design Web Frameworks for JavaScript Agile Project Methodology Advanced Web Development with JavaScript Packaging, Delivery, and Follow-up Specialization: Frontend, UX/UI From seeing these courses, what do you think are the benefits and disadvantages between these educations? I'm especially thinking about from stress, work life balance, amount of jobs etc.
- 12 replies
-
- cloud computing
- azure
-
(and 2 more)
Tagged with:
-
I'm unsure if I should study AWS or Azure. In my city in Sweden I find 200 jobs for AWS and 350 for Azure on the job database. I'm new to programming and only know Python and Java at high school level for reference. If I study AWS I will study Java and if I choose Azure I will study C# and basic Javascript. Do any of you have a suggestion on which cloudplatform to choose? Searching videos on YouTube it seems as if there's more videos on Java but perhaps it doesn't matter. I found BroCode to be excellent to learn basics for Python and Java. Update: I choose to study Azure. There's more job for Azure in Sweden and acording to an Azure consultant based in Sweden, most companies are centered around the Microsoft products; AD, AAD, Office 365 and Azure. The companies he meet that have a footprint in AWS are mostly looking to migrate to Azure.
- 15 replies
-
- cloud computing
- aws
-
(and 4 more)
Tagged with:
-
I have an index.js file that I want to load in the Node REPL to try some stuff, but when I use .load index.js in the REPL, it goes in an infinite loop and keeps repeating the first line in the file. const mongoose = require('mongoose'); I found an alternative solution which works in Ubuntu 20.04.5 in WSL2, which is to use the command node -i -e "$(< index.js)" in the terminal which loads the file perfectly fine and I can interact with its contents. But when I try the same command in PowerShell it gives me this error: < : The term '<' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:15 + node -i -e "$(< index.js)" + ~ + CategoryInfo : ObjectNotFound: (<:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException C:\Program Files\nodejs\node.exe: -e requires an argument The reason I'm asking about PowerShell "even though I use Ubuntu and things work there", is that I'm taking a web development course, and I provided the solution of using node -i -e "$(< index.js)" to people who were having the same issue, but other people can't get this to work in PowerShell, so I'm just trying to help. and I couldn't find any solution online to this .load issue, or to using an alternative to the node -i -e "$(< index.js)" command in PowerShell. index.js contents: const mongoose = require('mongoose'); mongoose.set('strictQuery', false); mongoose.connect('mongodb://localhost:27017/movieApp', { useNewUrlParser: true, useUnifiedTopology: true }) .then(() => { console.log("CONNECTION OPEN!!!") }) .catch(err => { console.log("OH NO ERROR!!!!") console.log(err) }) const movieSchema = new mongoose.Schema({ title: String, year: Number, score: Number, rating: String }); const Movie = mongoose.model('Movie', movieSchema); const amadeus = new Movie({ title: 'Amadeus', year: 1986, score: 9.2, rating: 'R' });
-
- javascript
- powershell
-
(and 2 more)
Tagged with:
-
my goal: for every "comment" load the childen (and run another function) and do the same for their childern etc etc etc. my test data = [ { "auth": "true", "children_comments": [ { "auth": "true", "children_comments": [ "can go on forever":true ], "comment": "<i>deleted</i>", "date": "5 months ago", "id": 784, "isOP": "false", "name": "<i>deleted</i>", "parent_id": 783, "user_icon": "{{URL}}" } ], "comment": "<i>deleted</i>", "date": "5 months ago", "id": 783, "isOP": "false", "name": "<i>deleted</i>", "parent_id": 777, "user_icon": "{{URL}}" } ] my python code that makes this array= comments_by_parent = defaultdict(list) for comment in data: comments_by_parent[comment['parent_id']].append(comment) for comment in data: comment['children_comments'] = comments_by_parent[comment['id']] ive tried simple For loops, For IN loops and nothing seems to work update: tried this, getting closer but not the same result function gothru(array) { if (Object.keys(array.children_comments).length >= 1) { console.log(array.children_comments) gothru(array.children_comments) //breaks here typeError: Cannot convert undefined or null to object return if (Object.keys(array.children_comments).length >=1) { console.log("e") gothru(array.children_comments) } } } JSON.parse(a).forEach(element => { gothru(element) });
-
So I have JS code at the top of the page mixed in with HTML. After the HTML is done I have a button with a separate <script> opening as it doesn't like code to be above it. Looks something like this: <script> declare variables var examplevar = 100; all functions </script> <button>on clic= Dofunctiononclick()</button <script> function Dofunctiononclick(){ alert(examplevar); } </script> but now that the script block was broken apart it's unable to reference what examplevar is, it's undefined because it's in a separate block above my button. A super simple fix, an amateur mistake but it's been such a long day my brain doesn't function anymore.
-
Needed a searchable select dropdown box and found a TomSelect library that has it all set up. I added in the required library. More specifically, this solution here. <link href="https://cdn.jsdelivr.net/npm/tom-select@2.0.0-rc.4/dist/css/tom-select.css" rel="stylesheet"> <script src="https://cdn.jsdelivr.net/npm/tom-select@2.0.0-rc.4/dist/js/tom-select.complete.min.js"></script> added in the JS code new TomSelect("#select-state",{ create: false, sortField: { field: "text", direction: "asc" } }); and everything works fine as intended until I realised that TomSelect filters out my text in said HTML dropdown selection. If one of my dropdown selection was meant to say: 1 - this is option "hello" then after implementing the TomSelect, it says instead this is option I assume filtering out elements before and after keys like - and ". Would love to know to disable this filter, or at least modify it so that the whole text of the option is displayed otherwise the point of a dropdown is sort of defeated. I was thinking of maybe tackling the attributes such as "field: "text"" but I have no idea where to begin or what other options could be. What would these SortField option be?
-
<h1> My First JavaScript </h1> <p id="demo"> </p> <button type="button" onclick="document.getElementById('demo').innerHTML = Date()"> Click me to display Date and Time </button> <button type="button" onclick="document.getElementById('demo').innerHTML = Date()"> Click me to display/hide Date and Time </button> <script title="Toggle Date"> var x = document.getElementById ('demo'); for (var i = 0; i < x.length; i++) // Looping through the HTML collection { if (x[i].style.display =="none") // Check if display is none { x[i].style.display = "block"; // If yes, set display to block } else { x[i].style.display = "none"; // Else, set display to none } } </script> Hi I'm using a .html file languages: html, css, javascript level: beginner problem: Button does not toggle the "Display/Hide date" Display example = "Thu Mar 24 2022 11:24:56 GMT+0100 (Central European Standard Time)"
- 6 replies
-
- beginner programmer
- html5 css
-
(and 1 more)
Tagged with:
-
Hi I'm using a .html file languages: html, css, javascript level: beginner problem: myFunction2() does not toggle the h2 class ("city") <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title> Use of The class Attribute in JavaScript </title> </head> <body> <h2> Use of the class Attribute in JavaScript </h2> <p> Click the button to hide/show all elements with the class name "city": </p> <button onclick="myFunction()"> Hide elements </button> <button onclick="myFunction2()"> Hide/Show Elements </button> <h2 class="city"> London </h2> <p> London is the capital of England </p> <h2 class="city"> Paris </h2> <p> Paris is the capital of France </p> <h2 class="city"> Tokyo </h2> <p> Tokyo is the capital of Japan </p> <p> <b> Note: </b> The element will not take up any space when the display property set to "none". </p> <script> function myFunction() { var x = document.getElementsByClassName ("city"); for (var i = 0; i < x.length; i++) { x[i].style.display = "none"; } } function myFunction2() { var x = document.getElementsByClassName ("city"); t.classList.toggle ("city"); for (var i = 0; i < x.length; i++) { x[i].style.display = "none"; } for (var i = 0; i > x.length; i--) { x[i].style.display = "block"; } /* if (x.style.display == "none") { x.style.display = "block"; } else { x.style.display = "none"; } */ } </script> </body> </html>
- 10 replies
-
- beginner programmer
- html5 css
-
(and 3 more)
Tagged with:
-
My code: events: { onPlay: function(e) { document.getElementById('theatermode').addEventListener('click', async function() { var t = { a: document.querySelectorAll('.bn35')[0], b: document.querySelectorAll('._1OVBBWLtHoSPfGCRaPzpTfe ')[0], } if (t.a.classList.contains("t2heater")&& t.b.classList.contains("t2heater")) { t.a.style.cssText = '' t.b.style.cssText = '' t.a.classList.remove("t2heater") t.b.classList.remove("t2heater") }else{ t.a.classList.add("t2heater") t.b.classList.add("t2heater") if (!t.a.classList.contains("t2heater") && !t.b.classList.contains("t2heater")) { t.a.classList.add("t2heater") t.b.classList.add("t2heater") } t.a.style.cssText = 'padding-left:15%;padding-right:15%' t.b.style.cssText = 'width:70% !important;' } }) } } Page markup: --title--- <div class= _1OVBBWLtHoSPfGCRaPzpTfe> <video loaded/ready =events.onplay.... > <div class=bn35> For some reason, the code above only fires Sometimes. The click does work, But the classList and csstext do not work, In google chrome, the DIVs flash (showing a change) but still not class or CSS text. help? These events are linked to my video player
-
Hello, I'm making a web-app-store but I can't seem to figure out a bit of custom code required to show the client paid for content and some other things. (JavaScript) Please keep in mind this is from an absolute noob perspective. I don't know any code or definitions beyond what || and && mean. I have a Wordpress page comparable to a Pokédex. It's supposed show a grayed out image of a pokémon for visitors but when someone aquires a license key from Gumroad it's supposed to show a swipeable image gallery. The code has to check for 2 licenses on Gumroad's servers. And as long as at least 1 is active, it has to show the image gallery. Here is Gumroad's explanation for checking a license: https://help.gumroad.com/article/76-license-keys curl https://api.gumroad.com/v2/licenses/verify \ -d "product_permalink=QMGY" \ -d "license_key=YOUR_CUSTOMERS_LICENSE_KEY" \ -X POST ^Here I have to fill in info about the product to check for. Then it gets back a response that looks like this, or a 404 error: { "success": true, "uses": 29, "purchase": { "seller_id": "kL0paVL1SdmJSYRNs-OCMg==", "product_id": "32-nPAinqpLj0B_WIwVlMw==", "product_name": "license product", "permalink": "testprod1", "product_permalink": "https://gum.co/testprod1", "email": "sample@example.com", "price": 0, "gumroad_fee": 0, "currency": "usd", "quantity": 1, "discover_fee_charged": false, "can_contact": true, "referrer": "direct", "card": { "bin": null, "expiry_month": null, "expiry_year": null, "type": null, "visual": null }, "order_number": 524459995, "sale_id": "FO8TXN-dvxYbBdahG97Y-Q==", "sale_timestamp": "2021-01-05T19:38:56Z", "purchaser_id": "5550311507811", "subscription_id": "GDzW4_NBdQy-o7Gjjng7lw==", "variants": "", "license_key": "85DB262A-C19D4B06-A5335A6B-8C079166", "ip_country": "India", "recurrence": "monthly", "is_gift_receiver_purchase": false, "refunded": false, "disputed": false, "dispute_won": false, "id": "FO8TXN-dvxYbBdahG97Y-Q==", "created_at": "2021-01-05T19:38:56Z", "custom_fields": [], "subscription_cancelled_at": "2021-02-05T20:09:27Z", "subscription_failed_at": null } } The conditional branch has to look for the succes = 'true' value, then it'll show the image gallery. Although, I don't know for sure if the succes value is for an active license or just for retrieving requested information. If refunded = true or succes = false it's supposed to be the grayed out image. I have 4 questions / problems: 1. How do I do the license check, let alone 2? Just paste it above the branch and the code as raw JavaScript on the gallery spot of the page? (I'm using a visual composer) 2. How do I connect the license check with the conditional branch or how do I pull info from that response? 3. Can I make it so only the paid for content gets retrieved from the server when the license is "ok"? (To prevent cache ripping or something like that.) 4. (Bonus) When you try to screenshot in your bank app, the screenshot is completely black. How do I do this? I came as far as putting this script on the page but it doesn't work: <span style="color: #1a1a1a;">if (e.keyCode == SYSQR) {</span> <span style="color: #1a1a1a;">filter:alpha(opacity=0);</span> <span style="color: #1a1a1a;">}</span> License checking script on page right now: <p>curl https://api.gumroad.com/v2/licenses/verify \ -d "product_permalink=QMGY" \ -d "license_key=YOUR_CUSTOMERS_LICENSE_KEY" \ -X POST </p> //Response from Gumroad's server comes here I guess, idk how to do this// if ('succes' = true) { echo <p>[vc_row][vc_column][us_image_slider ids="1868,432,87" css="%7B%22default%22%3A%7B%22background-image%22%3A%222237%7Cfull%22%2C%22background-position%22%3A%2225%25%22%2C%22background-size%22%3A%22cover%22%2C%22background-repeat%22%3A%22no-repeat%22%2C%22background-attachment%22%3A%22fixed%22%2C%22border-radius%22%3A%228px%22%7D%7D"][/vc_column][/vc_row]</p>; else if ('refunded' = true || 'succes' = false) { <p>[vc_row][vc_column][us_image image="607"][/vc_column][/vc_row]</p> } } Thanks in advance!
- 5 replies
-
- javascript
- wordpress
-
(and 1 more)
Tagged with:
-
So the company that I'm working for is switching to web based software for a lot of my work. Previously we had used a desktop software that allowed keyboard shortcuts to navigate the entire interface without ever touching the mouse and I fell in love with this style of using the computer because of how fast it is. Well with the new software I am much slower and have been looking into extensions to allow me to accomplish this within the web app. One option I found was the extension Vimium. It is essentially perfect except for one major flaw. From what I've been able to find it can't interact with javascript elements on pages. Is there a way to make it work with that? Or, is there an alternative program that operates the same way?
- 3 replies
-
- javascript
- vimium
-
(and 1 more)
Tagged with:
-
Hey all. The program that I am currently taking contains a web development course and I have no idea about the workflow or tools involved with it. All that we're dealing with this semester is JS, CSS/HTML, AJAX and JSON so nothing too crazy (Next semester is server side stuff). I am extremely familiar when it comes to the workflow and toolchains of compiled/interpreted applications using languages like C/C++, Java, C#, Python, ASM but web development is extremely far out of my wheel house so I have no idea what tools and workflows are available for it. So far my setup is VS code with a live server extension and chrome but after using this for nearly 3 months out of this semester it still feels clunky to design and test web pages. I find it counter intuitive to have to reload the page every time I make a change, especially when I am working with forms and have to program the functionality for them. When I am working on the pages it is very iterative. I'll get the elements on the page and then program the required functionality for them before I style the page. But as I make changes I am constantly reloading and testing these changes, It helps in the long run making sure the page functions exactly as I want it too so that I get excellent grades but it is also a massive time sink to do so. The way I see it, I have 4 possible options. Change my workflow Change my tooling to benefit my work flow A mixture of the two above choices. Just live with it. Any thoughts for improving my workflow or toolchain? It would be great to have WYSIWYG (What you see is what you get) type of editing so that I can make changes on the fly without having to go through the process of retesting the entire page but rather just the section I need to retest. Additionally, I find the debugging experience to be lack luster at best; although, that might just be my naivety when using chromes developer tools.
- 3 replies
-
- web
- javascript
-
(and 2 more)
Tagged with:
-
On Desktop, it works fine, but on mobile, the mobile-keyboard closes for no reason <video> Untitled Project2.mp4 sorry about the video "edits" it was kinda rushed, and didnt take the time to do it cleanly here is all the source code for the editor https://git.nrrinc.net/CLeditor-3.6 (note: this was built for jquery 1.3, but it was updated to work with Jquery 3.6) could anyone point me in the right way to fix this bug?
-
I've recently got into programming using HTML and CSS. But now I've decide to take this seriously so I want to either learn JavaScript or Python i want to do both game development and web development ( im more interested in games though) so I'm need help and some advice.
-
< var color = 0; var fontFamily = 0; var fontSize = 0; var quote = 0; //if else statement to figure out what options were selected color = getText("colorInput"); fontFamily = getText("fontFamilyInput"); fontSize = getNumber("fontSizeInput"); quote = getText("quoteInput"); //if else statement to display stuff if (color == "lightblue" && fontFamily == "ariel" ) { setText("feedbackOutput", ":)"); } else if (color == "lightyellow" && fontFamily =="Comic"){ setText("feedbackOutput", "nice font bro" ); } else { setText("feedbackOutput", "lookin good!"); } //update screen as you type onEvent("quoteInput","input", function ( ) { updateScreen(); } //update screen for color }); //set function for all items function updateScreen (){ setText( "quoteOutput", quote); setProperty("quoteOutput","font-family", fontFamily); setProperty("quoteOutput","background-color", color); setProperty("quoteOutput","width", fontSize); setProperty("quoteoutput","height",fontSize); }> on line 31, i get this:
-
I am looking forward on earning income from programming, I have a very very basic knowledge in Popular languages, But haven't excelled in anyone. I wish to master either Python or JavaScript... The thing I worries about JS -- A lot of Frameworks and Libraries to keep Up with The things I worry about Python -- A lot of people mastered it, worried that that may reduce the demand -- I am not actually sure what will I do as Freelancing Project if I master Python.
- 3 replies
-
- programming
- python
-
(and 1 more)
Tagged with: