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 9 of 9
  • Thread Tools
  • Rate This Thread
  1. #1
    New to the CF scene
    Join Date
    Apr 2016
    Location
    Thornlie, Western Australia
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question How to accept 'N', randomise 0, 1, ... N, then display result within html code.

    Hallo

    Beginning with a html file, say index.html, how do I 'embed' within it Javascript to do the following?

    I have done it in Fortran but that requires a user to download an .exe file in order to use the program.

    The task is:

    • Accept via the keyboard an integer 'N', where N is greater than zero.
    • (A user would be given the option of entering zero or less to terminate the program).
    • Verify that N is within the range (inclusive) 1 to an upper positive limit.
    • Randomise the sequence 0, 1, .... N.
    • Display the randomised sequence on the screen so it may be copied or printed.


    This is the real task of truly random voting, or more precisely pseudo-random, as a mathematical algorithm cannot be truly random.
    But 'random-enough' is good enough
    Zero is included as even a single candidate presents options - Yes/No or 1/0.

    Thanking the reader, in anticipation.

    Eric in Thornlie, Western Australia.

  2. #2
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    4,556
    Thanks
    14
    Thanked 476 Times in 471 Posts
    Beginning with a html file, say index.html, how do I 'embed' within it Javascript
    by using script tags.

    if you need a start with JavaScript, check out MDN.
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  3. #3
    Senior Coder coothead's Avatar
    Join Date
    Jan 2004
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    2,192
    Thanks
    0
    Thanked 336 Times in 329 Posts
    Hi there eric_carwardine,

    and a warm welcome to these forums.

    check out the attachment, to see a possible solution.

    coothead
    Attached Files Attached Files
    ~ the original bald headed old fart ~

  4. #4
    New to the CF scene
    Join Date
    Apr 2016
    Location
    Thornlie, Western Australia
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile

    Quote Originally Posted by Dormilich View Post
    by using script tags.

    if you need a start with JavaScript, check out MDN.
    And MDN certainly looks like a good place to start, Dormilich Many thanks for the link. The more I see of Mozilla the more impressed with it I become.

  5. #5
    New to the CF scene
    Join Date
    Apr 2016
    Location
    Thornlie, Western Australia
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile

    Quote Originally Posted by coothead View Post
    Hi there eric_carwardine,

    and a warm welcome to these forums.

    check out the attachment, to see a possible solution.

    coothead
    Thank you for the welcome, coothead; it is much appreciated

    The attachment was a very possible solution! Can I attribute the code to you, in some way? If not to you directly then perhaps to this forum.

    Eric ~ most impressed

  6. #6
    Senior Coder coothead's Avatar
    Join Date
    Jan 2004
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    2,192
    Thanks
    0
    Thanked 336 Times in 329 Posts
    Hi there eric_carwardine,

    Can I attribute the code to you, in some way?
    I am just an amateur who codes for the mental stimulation that it
    provides and with the hope that it may stave of senile dementia.

    If the code in any way suits your purpose, please feel free to use
    it however you like, and with no strings attached.

    coothead
    ~ the original bald headed old fart ~

  7. #7
    New to the CF scene
    Join Date
    Apr 2016
    Location
    Thornlie, Western Australia
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    Quote Originally Posted by coothead View Post
    Hi there eric_carwardine,



    ... and with the hope that it may stave of senile dementia.
    Yes, this dementia is an insidious thing; you catch it from your children, I'm told {glum smilie}

    I think I'll immunise myself by becoming 'Speaker on Anything' (Speak anywhere, except possibly the Antarctic - too many ants - on any topic).

    Quote Originally Posted by coothead View Post
    Hi there eric_carwardine,


    If the code in any way suits your purpose, please feel free to use
    it however you like, and with no strings attached.
    Okay, thanks I'll probably include a link saying something like "Code generously supplied through CodingForums.com"

    P.S. How does one add a signature, as in your reference to hairless flatulence? I had expected to be able to do so by editing my profile but cannot see a way of so doing.

    Eric

  8. #8
    Senior Coder coothead's Avatar
    Join Date
    Jan 2004
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    2,192
    Thanks
    0
    Thanked 336 Times in 329 Posts
    Hi there Eric

    The signature editing is reached by "Settings" > "My Settings" > "Edit Signature".

    I have a sneaky suspicion, though, that this facility is only made available to those
    who have made a specified number of posts.

    You would need to check my assertion with a moderator, just in case I have suffered
    another one of my "Senior Moments" or, as I prefer to call to them; "brain farts".

    coothead
    ~ the original bald headed old fart ~

  9. #9
    New to the CF scene
    Join Date
    Apr 2016
    Location
    Thornlie, Western Australia
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Lightbulb

    Quote Originally Posted by coothead View Post
    Quote Originally Posted by coothead View Post
    I have a sneaky suspicion, though, that this facility is only made available to those
    who have made a specified number of posts.

    Ah-hah! Yet one more possible example of the world being ruled by algorithms

    Quote Originally Posted by coothead View Post
    The signature editing is reached by "Settings" > "My Settings" > "Edit Signature".
    Your suspicion could be well-founded coothead, when I look at "My Settings" Unless my installation of the forum is disadvantaged I may not yet have reached the critical number of posts.

    Quote Originally Posted by coothead View Post
    You would need to check my assertion with a moderator, ...
    I shall not bother them. I'm sure their attention is being claimed by matters more imperative than my deprivation

    Quote Originally Posted by coothead View Post
    just in case I have suffered
    another one of my "Senior Moments" or, as I prefer to call to them; "brain farts".
    Ears were invented for relieving the pressure of cranial flatulence, the bone structure of the auditory canal serving as a non-return valve in case the relief should occur while submerged.

    However
    , when relief in a marine environment is indicated there is one thing the reliever should never, never, never do.

    "Ewik" - My signature


 

Tags for this Thread

Posting Permissions

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