Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Jun 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Please help me with a javascript/html problem

    I tried to create a cypher encoder and decoder, but the code will not run. Please help me.


    The encoder
    <html>

    <body>
    <script>
    alert("Welcome to my cypher generator")
    alert("Please only type letters of the alphabet")
    alert("and use _ for spaces")
    var _ = `
    var a = key * 1
    var b = key * 2
    var c = key * 3
    var d = key * 4
    var e = key * 5
    var f = key * 6
    var g = key * 7
    var h = key * 8
    var i = key * 9
    var j = key * 10
    var k = key * 11
    var l = key * 12
    var m = key * 13
    var n = key * 14
    var o = key * 15
    var p = key * 16
    var q = key * 17
    var r = key * 18
    var s = key * 19
    var t = key * 20
    var u = key * 21
    var v = key * 22
    var w = key * 23
    var x = key * 24
    var y = key * 25;
    var z = key * 26;
    var letternums = prompt("Please enter the number of letters in your message.");
    var spacenums = prompt("Please enter the number of spaces in your message.");
    var nums = spacenums + letternums
    var avariable = 0
    while(avariable != nums)
    avariable = avariable + 1
    var cypherletters = prompt("Enter the first letter or _")
    alert("That equals letter or _ ", cypherletters)
    </script>
    </body>

    </html>


    The decoder
    <HTML>

    <HEAD>
    <title>Cypher Decoder
    </title>
    </HEAD>

    <BODY>
    <script>
    var key = prompt("ENTER THE KEY")
    var: = "SPACE"
    var 1 * key = a
    var 2 * key = b
    var 3 * key = c
    var 4 * key = d
    var 5 * key = e
    var 6 * key = f
    var 7 * key = g
    var 8 * key = h
    var 9 * key = i
    var 10 * key = j
    var 11 * key = k
    var 12 * key = l
    var 13 * key = m
    var 14 * key = n
    var 15 * key = o
    var 16 * key = p
    var 17 * key = q
    var 18 * key = r
    var 19 * key = s
    var 20 * key = t
    var 21 * key = u
    var 22 * key = v
    var 23 * key = w
    var 24 * key = x
    var 25 * key = y
    var 26 * key = z
    var nums = prompt("ENTER THE NUMBER OF NUMBERS")
    var variable = 1
    var cyphernums = prompt("Enter a number or `")
    alert("That number or ` equals", cyphernums)
    while (variable != nums)
    cyphernums = prompt("Enter a number or `")
    alert("That number or ` equals", cyphernums)
    variable = variable + 1
    </script>

    </BODY>

    </HTML>


    I am new to html/javascript and cannot fix this problem. Please help me.

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,603
    Thanks
    0
    Thanked 645 Times in 635 Posts
    You can't just invent your own language and expect it to work.

    While you have a few JavaScript debugging calls there - prompt and alert - most of the rest of the code makes no sense. With your first code the first var statement is nonsense and with the second script the second var is nonsense so none of the rest of your code wuould run even if it did make any sense.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #3
    New to the CF scene
    Join Date
    Jun 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Is there anything I could do to fix it?

  • #4
    New to the CF scene
    Join Date
    Jun 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Please post in the comments a working version if you can.

  • #5
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,603
    Thanks
    0
    Thanked 645 Times in 635 Posts
    I can't tell what it is that the code is supposed to be doing as it makes no sens whatever. Have you thought about actually learning a language such as JavaScript and see if you can at least make a start using that?

    For example in JavaScript you use a form in the HTML to collect information and you can output to the web page by using innerHTML. You then attach event listeners to the form to run the script when the form has information entered into it.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •