JavaScript Text Parser Fails to Function

I've been thinking about creating a text parser and have spent some time researching the topic.

Although I know that JavaScript may not be the ideal choice for building text parsers, it's currently the only scripting language I'm comfortable with.

This is what my code looks like at the moment:

<script>
  function makeCode() {
    for (i = 0; i < userCode.length; i++) {
    if (userCode.substring("print:"(0, 6)) {
      document.write(usercode.substring("print:"(6,0));
  }
</script>

<style>
  p {
    text-align: center;
    color: #cc0000;
  }
  h1 {
    text-align: center;
    font-family: Impact;
    color: #cc0000;
  }
  body { 
    text-align: center;
  }
  form {
    text-align: center;
  }
</style>
<h1>NCPL</h1>
<p style="font-size: 10px">In Browser NinjaCorp Programming Language Editor</p>
</head>
<body>
<form name="userCode">
    <textarea id="userCode" name="userCode" cols="80" rows="20" placeholder="Type your code     here"></textarea></br>
    <a href="javascript:makeCode()"><button type="button">Run Code!</button></a>
</form>

Answer №1

Are you searching for this specific solution?

function createBody() {
    var inputCode = document.getElementById('inputCode').value;
    var displayDiv = document.getElementById('displayDiv');
  
     // alert(inputCode)
    for (i = 0; i < inputCode.length; i++) {
       displayDiv.innerHTML =  displayDiv.innerHTML  + inputCode.substring((i,i+6)) +'<br>'; 
    }

}
p {
    text-align: center;
    color: #cc0000;
  }
  h1 {
    text-align: center;
    font-family: Impact;
    color: #cc0000;
  }
  body { 
    text-align: center;
  }
  form {
    text-align: center;
  }
<div id="displayDiv"></div>

<h1>NCPL</h1>
<p style="font-size: 10px">In Browser NinjaCorp Programming Language Editor</p>
</head>
<body>
  
<form name="inputCode">
    <textarea id="inputCode" name="inputCode" cols="80" rows="20" placeholder="Type your code     here">Typing here so there is some text to work with </textarea></br>
    <a href="javascript:createBody();"><button type="button">Run Code!</button></a>
  
</form>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Converting JSON to CSV using Node.js

Looking to convert JSON data to a CSV file in Node.js? Wondering if there are any predefined modules for this task? P.S. Additionally, interested in incorporating formatting such as including headers like "MONTHLY REPORT" and row colors? ...

Retrieving dates from a database and populating them into a jQuery UI Picker using PHP

I need to retrieve dates from the database using PHP and highlight them in a datepicker. Here is how I am attempting to accomplish this: HTML Date: <input type="text" id="datepicker"> // Static dates // An array of dates var eve ...

Angular generates an array that is not native to the system

When I directly set vm.files in my view using the following code: <input type="file" ng-model= vm.files[0]> <input type="file" ng-model= vm.files[1]> The contents of vm.files are displayed as shown in example A: https://i.stack.imgur.com/K3V ...

Steps to Deactivate Website Address in a Browser

I need to ensure that users cannot edit the URL of my website. Specifically, when a user logs into my website they should be directed to studenthome.aspx and the URL (www.XXXXXX.com/studenthome.aspx) should not be editable. I have searched online and fou ...

What is the best way to eliminate a duplicate item from the shopping cart without actually deleting it?

I developed an e-commerce platform with a cart feature using the context API. However, I encountered an issue where removing one item from the cart also deletes another item if there are two of the same items in the cart. How can this be prevented? Below ...

tips for modifying html element attributes using angular

I am working with an element that is automatically generated through an API call as <a target="_blank" href="http://www.work.com/reward"><b class="orange tdu">My Work History</b></a> and now I want to modify it like <a ng-cl ...

Applying style changes to the height on scroll event in Javascript for Chrome, Firefox, and Internet Explorer

I am working on triggering an event when scrolling to a specific height. I have code that successfully adds a style in Chrome, but it is not functioning properly in IE. Can anyone provide assistance? myID = document.getElementById("subnav"); var mySc ...

Is it possible for a conditional type in TypeScript to be based on its own value?

Is it possible to use this type in TypeScript? type Person = { who: string; } type Person = Person.who === "me" ? Person & Me : Person; ...

Employing ngModel within an (click) event in Angular 4

I have this html code snippet: <div class="workflow-row"> <input type="checkbox" id="new-workflow" [(ngModel)]="new_checkbox"> <label>New Workflow</label> <input type="text" *ngIf="new_checkbox" placeholder="Enter ...

Using JavaScript to fetch elements by their ID along with a button

UPDATE: I have corrected the semi-colons, case sensitivity, and brackets in the code. It functions properly if I eliminate the functions after buttonPARTICULAR! Why is that? UPDATE: Issue resolved. My mistake. Apologies!!! :-Z When I simplify it like thi ...

Add data to a DataTable without the need to manually refresh the page

I am looking to dynamically append a DataTable on my webpage. The goal is to have a form that users can fill out multiple times and each time they submit their inputs, the results will be added to the DataTable for display. <table id="table" class="di ...

Is it possible to use a webcam to scan a QR code directly into a webpage?

Is it possible to enable users to input data on a webpage using QR code scanning? I'm unsure if there is a tool that can be integrated into the page or paired with a library to make this happen, or if I need to consider an external solution beyond th ...

Unlocking the value of data within a nested object in React: A guide

Recently, I have started working with React and am encountering a challenge in accessing data nested within an object. My goal is to develop an application that compares today's date with the dates in a list, and if the condition is met, display the c ...

Modifying the attributes/properties within a class of a bootstrap button

Here is the code that I have: <b-button id="search-button" size="md" class="mt-1 w-100" type="submit" @click="someEvent()" >Example </b-button If we imagine calling someEvent() and wanting to modi ...

Utilizing this method for declaring functions in Angular

I'm currently learning about Angular and attempting to implement a controller. However, I've run into an issue where the ng-click is not working (the function is not being called). According to the Chrome extension Batarang, the function is defin ...

How can a default option be shown at the top of a select dropdown list in AngularJS with dynamic content?

Objective: Arranging a default <option> to always be displayed at the top of a <select> dropdown upon opening. I am making progress towards my objective. We currently have a dropdown that dynamically populates based on selected elements, with ...

Executing a Vue method from the main.js file within a Vue.js document

Why can't I call my method in App.vue? Shouldn't the div with id='App' in the App file allow me to access methods within it? Main.js new Vue({ render: h => h(App), methods:{ gesamt:function () { return 'Hello&a ...

Generating a JSON Object by combining elements from multiple arrays

I need assistance in creating a single Json object from two arrays using JavaScript or jQuery. The data is stored in the database in the format shown below: clob_field_1: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 etc etc ... clob_field_2: 8106.23, 7856.49, 8009.15, ...

Why do I keep encountering a null window object issue while using my iPhone?

Hey there! I've got a React game and whenever the user loses, a new window pops up. const lossWindow = window.open( "", "", "width=500, height=300, top=200, left = 200" ); lossWindow.document.write( & ...

What is the method to obtain the value of a <select> element using JavaScript?

How can I extract and transmit data using PHP? I am able to retrieve values from text input, but struggling with other types of input like select dropdowns. My goal is to send these values via email through a combination of AJAX and PHP. Here is the HTML ...