-2

new to HTML/Javascript

Trying to create a HTML form that takes in 6 different input values from user, which are all integers.

on submit will then output a text file which is just lines of text which have the inputs in bedded

example ask for inputs input1 : input2 : input3 : input4 : input5 : input6 :

then on submit have a text file generated with

command1:input1input2:command2,test

command1:input3input4:command2,test

command1:input4:command2,test

command1:input5:command2,test

command1:input6input2:command2,test

essentially its a form, repeating same set of strings in a text, but the inputs are taken into account.

sorry about the missing example here it is

i have been using alerts, and want to switch this to writing the alerts line by line into a text file and download it..

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>
      TEST FORM
    </title>
    <script language="JavaScript" type="text/javascript">
//<![CDATA[
    function testResults (form) {
    var TestVar1 = form.inputbox1.value;
    var TestVar2 = form.inputbox2.value;
    var TestVar3 = form.inputbox3.value;
    var TestVar4 = form.inputbox4.value;
    var TestVar5 = form.inputbox5.value;
    var TestVar6 = "command" + TestVar1 + TestVar2 + "command2"

    alert ("command1: " + TestVar1 );
    alert ("command2: " + TestVar2 + TestVar2 + "command5");
    alert ("command3: " + TestVar3 + "command5;;:" + TestVar2);
    alert ("command4: " + TestVar4 + "command1;;" + TestVar2);
    alert ("command5: " + TestVar5 + "command2" + TestVar2);
    alert ("command6: " + TestVar6 + TestVar2);
                            }
    //]]>
    </script>
  </head>
  <body>
    <form name="myform" action="" method="get" id="myform">
      Enter something in the box:<br />
      <label for="input1">input1</label> <input type="text" name=
      "inputbox1" value="" id="input1" />
      <p>
        <label for="input1">input2</label> <input type="text" name=
        "inputbox2" value="" id="input2" />
      </p>
      <p>
        <label for="input1">input3</label> <input type="text" name=
        "inputbox3" value="" id="input3" />
      </p>
      <p>
        <label for="input1">input4</label> <input type="text" name=
        "inputbox4" value="" id="input4" />
      </p>
      <p>
        <label for="input1">input5</label> <input type="text" name=
        "inputbox5" value="" id="input5" />
      </p>
      <p>
        <input type="button" name="button" value="Click" onclick=
        "testResults(this.form)" />
      </p>
    </form>
  </body>
R H
  • 1
  • 1
  • 1
    So what have you tried so far? Where is the relevant source code to your question and which specific part have you having problems with? Please keep in mind this isn't a free writing service so if you have no intentions of trying/researching yourself then I suggest you hire a developer. – NewToJS Dec 07 '17 at 01:09
  • Too broad, you have several problems to solve here. Not the least of which is: https://stackoverflow.com/a/21016088/4665. Break your problem down into smaller parts. Ask a question about each of the parts you have problems with. Start by at least writing the HTML form. Write javascript to get the values. If you have problems with those 2 steps, ask a specific question about what you have tried. Next tackle the problem of saving the data. – Jon P Dec 07 '17 at 01:21

1 Answers1

0

Forms send all input data to a server/webpage which processes the input into whatever it is needed (in your case it's just printing the inputs in a line).

The general form structure:

<form action="send_to_this_server_or_webpage.html" method="get (or) post">
   Input 1: <input name="parameter_name" type="text (or) number">
   ...
   <input type="submit" value="Submit">
</form>

Then in the HTML page that is receiving the incoming form, you would write Javascript to get your values from the parameters (names) that you set in your HTML form.

P.S. Your question is a bit confusing as to what exactly you want to perform but my answer is the general way of retrieving values from forms using parameters.