Jump to content

Search the Community

Showing results for tags 'node.js'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Calendars

  • Community Calendar

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

Found 14 results

  1. Hey guys, I need your help with a problem I’ve been able to walk around so far. Namely, I want to make a mysql query in a node.js web socket: connection.query("SELECT * FROM DB WHERE id= ?;", [id], function(error, results, fields) { if (error) throw error; // Code here... }) In the variable results I can now use the data in the form of a JSON object. That’s not a problem. So far, I have done this so that when I wanted to make several queries, I have nested into each other. Like this: connection.query("SELECT * FROM DB WHERE id= ?;", [id], function(error, results, fields) { if (error) throw error; connection.query("SELECT * FROM DB WHERE id= ?;", [id], function(error, results, fields) { if (error) throw error; // Code here... }) }) But now I need that some queries are only carried out if certain conditions are met. As a result, the queries can no longer be logically nested. That’s why I need something like this: if(a == b) { connection.query("SELECT * FROM DB WHERE id= ?;", [id], function(error, results1, fields) { if (error) throw error; // Code here... }) } if(c == b) { connection.query("SELECT * FROM DB WHERE id= ?;", [id], function(error, results2, fields) { if (error) throw error; // Code here... }) } And after both if loops I can logically no longer access the values results1 and results2. How can I do that? Do you need more information. I hope for some answers. Yours, Ben
  2. I want to feed some input files stored in an array to a ffmpeg childprocess , but it needs to be asynchronous because I want to capture std.err live. However I need to feed one input at a time waiting for the previous one to finish. I think I need to use promises or async await but I cannot work out how. my code (simplified) is: var inputArray =['"'+"firstFile"+'"' ,'"'+"secondFile"+'"' ,'"'+"third"+'"' ]; var spawn = require('child_process').spawn; for(i=0;i<inputArray.length;i++){ child = spawn("ffmpeg",["-y", "-i",inputArray[i],+i+".ts"],{ shell: true}); child.stderr.on('data', function (fdata) { var datastring = fdata.toString(), lines = datastring.split(/(\r?\n)/g); for (var b=0; b<lines.length; b++) { document.getElementById("show").innerHTML = lines[b]; } }); child.on('exit', function (code) { console.log("code "+i+" "+ code); }); } Thanks in advance
  3. Newbie alert... I am an experienced Un*x sysadmin and programmer. However, JavaScript and its huge ecosystem can be overwhelming. My main target now is Node.js. I have been locating, downloading and installing a lot of packages: npm install this npm install that npm install the-other npm install one-more The input is always whole directories. I just found out that jQuery is very important, so I decided to install it. The problem is that in the official site they offer one single file. It is ASCII with the extension *.js https://jquery.com/download/ That doesn't feel right. A rather large system, contained in one text file? TIA, -Ramon F. Herrera JFK Numbers
  4. Hello, I am trying to build an UI using Electron but I have only one problem keeping me from finishing it. I want to save the text from some html inputs at the press of a button without any pop-ups. I know it has something to do with fs but I don't know how to implement it. Thanks in advance!
  5. I try to learn Node.js. I have used Mamp and PHP till now. With Mamp I can access to MySql. Is that useful for Node? Probably I am confusing concepts and Mamp does not work with Node. Right? .
  6. Hi , I am not familiar with javascript at all , I am going to learn node.js (I have a good background in python , c ) now , I don't know where to start, should I master js then go for nodejs , or a basic learning of js is adequate for nodejs or... I will appreciate if you suggest useful sources and websites to learn . Thanks in advance
  7. Hello. Any one here as experience with ionic 4 and express? I'm trying to do something simple: A simple login form for the user to enter login and password and a connect button. Once the user click on connect to send the data to the server. I wanna see the data on the server side maybe using an alert. Can anyone help me with that? It's been a couple of days I'm trying it. Please notice that I'm not trying something complex and the goal is to understand the concept, therefore the use of error handling, or whatever other utility to make the connection strong isn't necessary at all. Thanks ahead of time.
  8. I copied the code straight from https://www.w3schools.com/nodejs/shownodejs_cmd.asp?filename=demo_events_open open.js var fs = require('fs'); var readStream = fs.createReadStream('./demofile.txt'); /*Write to the console when the file is opened:*/ readStream.on('open', function () { console.log('The file is open'); }); Upon executing "node open.js" in the terminal, "The file is open" appears in the terminal, then the program terminates. It always happens, even if I don't have demofile.txt open in Notepad or any other program. Not sure why this is happening? When I instead use the string 'close', the console never prints anything out, regardless as to demofile.txt is open or closed. This behavior has happened on both my Windows machine and Raspberry Pi. Tried putting the above code inside a http.createServer statement, but then I get no output at all in the console. Although I suppose that would be unnecessary.
  9. Hey there, I have followed the tutorial for the w3 raspberry pi led pwm Gpio controller using node.js (https://www.w3schools.com/nodejs/nodejs_raspberrypi_rgb_led_websocket.asp) unfortunately though it uses internal scripts and stylesheets. I have tried using express.static to set up file hosting but I couldn’t get it to work. I am needing to host additional files for the web server to read. I am fairly new at node.js so it might have been the way I was trying to implement it that caused the issue. Thanks in advance
  10. What About Adding Node.js As Another Tutorial In The Server-Side Languages? to complete the chain of JavaScript and to teach the newer, modern and the attractive part of the language...why not? I am not recommending specific framework W3SCHOOLS can choice any of the available, but please the best! WHY ADDING: I am not here to explain the power of Node.js...Please Google this WHY IT'S NECESSARY: Large companies are using and coming to Node e.g...[Google this also ], and large apps are written with it[Do Not Forget Our friend..Google]. not only it's "Popular", but also fast(because of the non-blocking I/O, being V8 based and more[Google!!!]) THANKS FOR: ADDING NODE AS THE THIRD LANGUAGE
  11. When will you add react.js, express.js,angular2, Zurb foundation(web framework),Ruby on Rails and node.js classes(which very commonly used for most of the websites)?
  12. w3schools.com Is Amazing Resource For Those Who Would Like To Learn Web Development,Adding A Node.js Tutorial To It Will Make The Site Better,Since W3schools Is Presenting The Web Development Ideas In A Simplified Way...
  13. Hi, I am using express framework form to get inputs from user and sending it as email by using node mailer. However i am unable to receive the image and system type (Combo box).I am new to node.kindly help. ### My HTML code ``` <div class="container"> <p style="font-size:24px;">ONLINE SUPPORT REQUEST</p> <hr size="2%;"width="50%;"> <form role="form" name="myForm" onsubmit="return(validate());" action="http://127.0.0.1:8081/process_post" method="POST" > <div class="form-group"> <label for="name">What is your name?</label> <input type="text" class="form-control" id="text" name="fname" placeholder="name"> </div> <div class="form-group"> <label for="cname">What is your company name?</label> <input type="text" class="form-control" id="text" name="cname" placeholder="company name"> </div> <div class="form-group"> <label for="email">What is your email address?</label> <input type="email" class="form-control" id="email" name="email" placeholder="Enter email"> </div> <div class="form-group"> <label for="phone">What is your phone number?</label> <input type="text" class="form-control" id="text" name="phone" placeholder=" phone number with area code"> </div> <div class="form-group"> <label for="one">Is this an emergency? </label> <input type="radio" class="form-control" id="text" name="emergency" value="No"> NO <input type="radio" class="form-control" id="text" name="emergency" value="Yes"> YES </div> <div class="form-group"> <label for="one">Do you require a phone call when we begin working on your ticket? </label> <input type="radio" class="form-control" id="text" name="phonecall" value="No"> NO <input type="radio" class="form-control" id="text" name="phonecall" value="Yes"> YES </div> <div class="form-group"> <label for="combo" name="systemtype"> What is your system platform</label> <br> <select> <option value="volvo">Microsoft Windows</option> <option value="saab">Mac OS X</option> <option value="opel">Linux</option> <option value="audi">IOS</option> <option value="5">Android</option> <option value="6">Others</option> </select> </div> <div class="form-group"> <label for="uploadfile"> Please attach a screenshot if applicable.</label> <input type="file" class="form-control" id="text" name="attachment" size="50"> <br> <input type="submit" value="Upload File" /> </div> <div class="form-group"> <label for="name">What is the subject of your support request?</label> <input type="text" class="form-control" id="text" name="supportrequest" placeholder="suport subject"> </div> <div class="form-group"> <label for="comment">Please describe the support issue in detail </label> <textarea class="form-control" rows="5" id="comment" name="urcomments"></textarea> </div> <button type="submit" class="btn btn-default">Submit</button> </form> </div> <br> ``` ### My server Code ```js var express = require('express'); var app = express(); var fs = require("fs"); var bodyParser = require('body-parser'); var multer = require('multer'); // Create application/x-www-form-urlencoded parser var urlencodedParser = bodyParser.urlencoded({ extended: false }) app.use(express.static('public')); var upload = multer({ dest: './uploads' }); app.get('/client-support.htm', function (req, res) { res.sendFile( __dirname + "/" + "client-support.htm" ); }) app.post('/process_post', urlencodedParser, function (req, res) { // Prepare output in JSON format response = { fname:req.body.fname, cname:req.body.cname, email:req.body.email, phone:req.body.phone, emergency:req.body.emergency, phonecall:req.body.phonecall, systemtype:req.body.systemtype, attachment:req.body.attachment, supportrequest:req.body.supportrequest, urcomments:req.body.urcomments }; console.log(response); res.end(JSON.stringify(response)); console.log(req.files.file.name); console.log(req.files.file.path); console.log(req.files.file.type); var file = __dirname + "/" + req.files.file.name; fs.readFile( req.files.file.path, function (err, data) { fs.writeFile(file, data, function (err) { if( err ){ console.log( err ); }else{ response = { message:'File uploaded successfully', filename:req.files.file.name }; } console.log( response ); res.end( JSON.stringify( response ) ); }); }); //sudan file upload edit end //sudan edited node mailer code below var nodemailer = require('nodemailer'); // create reusable transporter object using the default SMTP transport // setup e-mail data with unicode symbols var mailOptions = { from: 'xxxxxxxx.com', // sender address to: 'xxxxxxxxx.com', // list of receivers subject: 'Client Support Page - Client Details', // Subject line text: 'you have a new submission with folowwing details....Name:'+req.body.fname+'cname:'+req.body.cname+'Email:'+req.body.email+'Phone:'+req.body.phone+'emergency:'+req.body.emergency+'phonecall:'+req.body.phonecall+'systemtype:'+req.body.systemtype+'attachment:'+req.body.attachment+'supportrequest:'+req.body.supportrequest+'urcomments:'+req.body.urcomments, // plaintext body html: '<table border="1" style="width:100%"><tr style="background-color:#373737;color:#ffffff;"><td><b>DETAILS LIST</b></td><td><b>CLIENT DETAILS</b></td></tr><tr style="background-color: #eee;"><td><b>Name:</b></td><td>'+req.body.fname+'</td></tr><tr><td><b>Email:</b></td><td>'+req.body.email+'</td></tr><tr style="background-color: #eee;"><td><b>Phone:</b></td><td>'+req.body.phone+'</td></tr><tr><td><b>emergency:</b></td><td>'+req.body.emergency+' </td></tr><tr style="background-color: #eee;"><td><b>phonecall:</b></td><td>'+ req.body.phonecall +' </td> </tr><tr><td><b>systemtype:</b></td><td>'+req.body.systemtype +'</td></tr><tr style="background-color: #eee;"><td><b>attachment:</b></td><td>'+req.body.attachment +' </td></tr><tr><td><b>supportrequest:</b></td><td>'+ req.body.supportrequest +' </td></tr></table>'// html body }; // send mail with defined transport object transporter.sendMail(mailOptions, function(error, info){ if(error){ return console.log(error); } console.log('Message sent: ' + info.response); }); }) var server = app.listen(8081, function () { var host = server.address().address var port = server.address().port })
  14. Hello there, I am plan (in near future) to start with learning and training with node.js. Since I have habit to learn and remind from w3s (manner of writing), do you plan to add some tutorials and references for node.js? Thank you for all!
×
×
  • Create New...