0

I am a real beginner at codding in general. I would like to create a website that people can go onto and choose a character of a play we are doing. I would then like to prompt for their full name so that I can create a file in the folder for that button, that is under their name. In that same prompt I would like to type it "/WINNER/" and have that give me back a random name (file name) from that button's folder. I hope that makes scene, and I know that I might be making this overly complicated bet this is that only way I found of doing this. Also sorry if my code looks a little wonky, like I said I am a complete noob.

My index.html

<head>
    <title>Check Please | Enter</title>
    <link href="css/styles.css" rel="stylesheet" type="text/css" media="screen">
    <link href='http://fonts.googleapis.com/css?family=Gafata|Metrophobic' rel='stylesheet' type='text/css' media="all">
</head>

<body>

    <div id="Welcome">
        <div id="WelcomeMessage">
            <h5 class="redCenter">Welcome to the voting website of</h5>
            <h3 class="Musical">'Check Please the Musical'</h3>
        </div>      

        <div id="Enter-Img">
            <a href="choice.html">
                <img src="images/site/enter.png" width="438" height="241" class="button">
            </a>
        </div>      
    </div>   

</body>

Then my choice.html

<head>
    <title>Check Please | Voting</title>
    <link href="css/styles.css" rel="stylesheet" type="text/css" media="screen">
    <link href='http://fonts.googleapis.com/css?family=Gafata|Metrophobic' rel='stylesheet' type='text/css' media="all">
</head>

<body>

    <div id="Top">
        <h3 class="Musical">Please click on one of the following characters that you believe to be the murderer, and then enter your full name.</h3>
    </div>

        <div id="Button 1">
            <a href="Button 1/Button1.html">
                <img src="images/site/Person 1.png" width="438" height="241" class="enter">
            </a>
        </div>

        <div id="Button 2">
            <a href="Button 2/Button2.html" onclick="Name = prompt('Enter your first and last name')">
                <img src="images/site/Person 2.png" width="438" height="241" class="enter">
            </a>
        </div>

        <div id="Button 3">
            <a href="Button 3/Button3.html" onclick="Name = prompt('Enter your first and last name')">
                <img src="images/site/Person 3.png" width="438" height="241" class="enter">
            </a>
        </div>

        <div id="Button 4">
            <a href="Button 4/Button4.html" onclick="Name = prompt('Enter your first and last name')">
                <img src="images/site/Person 4.png" width="438" height="241" class="enter">
            </a>
        </div>

</body>

And right now I have only tried to mess around with one button (Button1.html):

<head>
    <title>Check Please | Thanks and Enjoy</title>
    <link href="../css/styles.css" rel="stylesheet" type="text/css" media="screen">
    <link href='http://fonts.googleapis.com/css?family=Gafata|Metrophobic' rel='stylesheet' type='text/css' media="all">
</head>

<body>

    <script type="text/javascript">
        window.onload(Name = prompt("Enter your first and last name below"))

        import java.io.PrintWriter;

        if(Name == "/WINNER/") {
            window.location.replace("http://stackoverflow.com");

        }else{

            import java.io.PrintWriter;

            PrintWriter writer = new PrintWriter(Name + ".txt", "UTF-8");
            writer.close();
        };
    </script>

    <div>
        <h3 class="Musical">Button 1</h3>
    </div>

    <div>
    </div>


</body>

Thanks for ANY input!!!!!!!

Ryan Ransford
  • 3,224
  • 28
  • 35

1 Answers1

3

You appear to be writing Java in a JavaScript context. I'll make one thing very clear: JavaScript is not related to Java. They are completely separate languages, and as such you cannot use Java libraries.

Also, you can't write out to any directories using JavaScript. JavaScript runs in the user's browser, which is separate from the server (you cannot access files within directories on the server)

triggerpuss
  • 136
  • 1
  • 3