Posts

Showing posts from April, 2019

Javascript array and changing an image with button

For the next experiment, it was trying to change an image by button click, and surf through the array in my javascript file.

Remember all files are in the same folder.

In my code, you'll see their paths.
Next experiment I will evolve the style more, and try to retrieve the image path from a(n) 'dictionary'/'object' constant instead.
The incrementor/counter once again came in quite handy. 

The images, the html, and the javascript.
In a an actual web app, with something like Django, the images would be in a static / images,  the html, in a templates, and the javascript in the static/js.
Making it work first is the goal, then moving the codes into the app.

 Video:





<!---    HTML file -->

<!DOCTYPE html>

<html>
<head>
<title>Exercise 2 Arrays</title>
 <script type="text/javascript" src="/home/nellie/Desktop/browser test/ex2.js"></script>
  </head>
  <!-- #91cac5 == greyish teal-->
  <body id=&…

Simple setInterval Javascript HTML interaction test

Image
Using the method from the previous post:

https://camelcasenoodles.blogspot.com/2019/04/a-simple-way-to-test-some-javascript.html

I have made these two files to try out the 'setInterval' in JavaScript.

picture of simple counter in a grey HTML page:






I left the 'alerts' in the functions.  If I'm not sure if a function is being called, I can un-comment the alert, and see if I had an error that is preventing the function from being called.
(I had GetElementById  instead of getElementById   &&  HTML will ignore anything it can't read  *I'll look this up one day soon to confirm* )

 No alert, the function is not being called.

Break it, modify it, experiment. 
May the spam be ever in your flavor.


***********  HTML  **********************

<!DOCTYPE html>

<html>
<head>
<title>Exercise 1</title>
<!-- your src will be different from mine.  see previous blog post linked at top -->
 <script type="text/javascript" src=&qu…

A simple way to test some javascript

Image
Not too long ago I set up an entire Django app just for testing out my JavaScript interactions.

Just this morning I realized I didn't have to do any of that.

Simply create a folder, ( I did it on my desktop directory)
and put your html, and referenced javascript in the same folder.

To run the html file, all you have to do is double click it, The computer will run the HTML file through your default internet browser.
As long as your path to the javascript file is correct in your HTML <script> tag that is located in the header, your javascript should run.  You can also change code and refresh the page on demand.  

Why I didn't know this sooner is kinda irritating.  So if your looking for a simple way to do this, and stumble across my blog post, maybe this is for you.



Example code below.

 --May the spam be ever in your flavor --

<!--           The HTML    --> 

<!DOCTYPE html>

<html>
<head>
<title> will it work?</title>
<script type="t…