Jump to content


  • Content count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About smus

  • Rank
  1. smus

    How to check if a string is empty

    Right, thanks
  2. smus

    How to check if a string is empty

    Added Dim es, fs but the result is the same. "The string is empty" for both cases
  3. How do we check if a given string is empty or not? I've tried isNull, isEmpty as well as equal and non-equal signs, the results are the same for empty and filled texts. My code looks like this: Call am(es) Call am(fs) es = "" fs = "ms" Sub am(s) if s <> "" then response.write "The string is not empty <br>" else response.write "The string is empty <br>" end if end Sub
  4. Wow, it works! But what if I am receiving a text from a <textarea>? Is it possible to somehow insert those literals, so that JS 'thought' it is an integral string?
  5. Hello, iwato! Well, basically, my goal is to make some manipulations with a string variable and it's ok with relatively small single line strings. But when I copy and paste a text from a .txt file and assign it to str, of course, there is an error, because JS is a line-break sensitive. So, I want to make multiline text become single line string programatically. For example, paste it to a textarea and then take it as a string from there. This code doesn't change the string: var e = str.indexOf("/n"); if(e != -1){ // if we have at least one line break in str, replace /n with space str = str.replace(/n/g," "); }
  6. My string variable is quite big and it contains line-breaks. I need to make it single lined to be detected by JS as usual string variable: initial condition: var str = "my string"; the string without line breaks: var str = "my string"; How can I detect those line breaks? By replacing '/n' symbols with spaces? Are there any other ways to deal with them?
  7. smus

    HTML Symbols: displaying a text as it is

    That's right, thanks! Didn't think about it. All ingenious solutions are so simple
  8. How to display a text as it is in HTML using only HTML tags? For example, I want special symbols like &amp; not to be interpreted by browser as &, but display as &amp; All I found is a deprecated <xmp> tag, it works, but it creates a new paragraph for every symbol.
  9. smus

    scoped attribute for <style>

    Excellent! Thanks, Ingolme!
  10. I tested the code on Firefox, but it also applies styles for the rest of the HTML file: <div> <style scoped> h1 {color:red;} p {color:blue;} </style> <h1>This is a heading</h1> <p>This is a paragraph.</p> </div> <h1>This is a heading</h1> <p>This is a paragraph.</p>
  11. No, those were just interview tasks with strict condition to use JS or one of its frameworks. But I decided to show that data from a form can, indeed, be added using push() method for arrays, if the json structure is inside html file. It works well, however, of course, the json data is not changing physically.
  12. May I refer to this topic, if an employer asks me to manipulate data from json file using javascript? Because it is already the second time they want me to do "something impossible"
  13. I know, but I have asked the same question on StackOverflow. Can you please consider their solution and advise me if there is a way to somehow use it in separate files? Here is the link: https://stackoverflow.com/questions/50590055/angularjs-inserting-data-to-a-json-file/50596513#50596513
  14. I have 3 files: html that is displaying data from json file using AngularJS, json file containing the data, script.js that stores the scripts. HTML file also has a form, from which I want to add data to my json file (onsubmit="insertData()"). insertData function is going to be in script.js I know, I may use .push method for this, but I don't know how to apply to the json file in this case. script.js var prg = angular.module('ajsprogram', []); prg.controller("outercont", function($scope, $http) { //function to display json file information $http.get('airlines.json').success(function(data){ $scope.info = data; $scope.airlineorder = 'airline'; }); }); function newairline(an,hb,ur,cs){ //new function to insert a data } airlines.json [ { "airline" : "British Airways", "hub" : "LHR", "url" : "http://britishairways.com", "callsign":"SPEEDBIRD" }, { "airline" : "Air France", "hub" : "CDG", "url" : "http://airfrance.com", "callsign":"AIRFRANS" }, { "airline" : "Virgin Atlantic", "hub" : "LGW", "url" : "http://virginatlantic.com", "callsign":"VIRGIN" }, { "airline" : "RyanAir", "hub" : "DUB", "url" : "http://ryanair.com", "callsign":"RYANAIR" }, { "airline" : "Emirates", "hub" : "DXB", "url" : "http://emirates.com", "callsign":"EMIRATES" } ]