Form using Javascript exclusively Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experience Should we burninate the [wrap] tag?creating and submitting a form with javascriptCreate GUID / UUID in JavaScript?How do JavaScript closures work?What is the most efficient way to deep clone an object in JavaScript?How do I remove a property from a JavaScript object?Which equals operator (== vs ===) should be used in JavaScript comparisons?How do I include a JavaScript file in another JavaScript file?What does “use strict” do in JavaScript, and what is the reasoning behind it?How to check whether a string contains a substring in JavaScript?How do I remove a particular element from an array in JavaScript?For-each over an array in JavaScript?

Disable hyphenation for an entire paragraph

How to recreate this effect in Photoshop?

Should I discuss the type of campaign with my players?

What LEGO pieces have "real-world" functionality?

Why did the IBM 650 use bi-quinary?

Bonus calculation: Am I making a mountain out of a molehill?

Why was the term "discrete" used in discrete logarithm?

Is there a concise way to say "all of the X, one of each"?

Should gear shift center itself while in neutral?

Should I call the interviewer directly, if HR aren't responding?

How can I fade player when goes inside or outside of the area?

What are 'alternative tunings' of a guitar and why would you use them? Doesn't it make it more difficult to play?

Right-skewed distribution with mean equals to mode?

Storing hydrofluoric acid before the invention of plastics

Are my PIs rude or am I just being too sensitive?

When to stop saving and start investing?

What do you call a plan that's an alternative plan in case your initial plan fails?

Does accepting a pardon have any bearing on trying that person for the same crime in a sovereign jurisdiction?

ListPlot join points by nearest neighbor rather than order

How widely used is the term Treppenwitz? Is it something that most Germans know?

Is there a documented rationale why the House Ways and Means chairman can demand tax info?

If Jon Snow became King of the Seven Kingdoms what would his regnal number be?

If a contract sometimes uses the wrong name, is it still valid?

Is the address of a local variable a constexpr?



Form using Javascript exclusively



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
The Ask Question Wizard is Live!
Data science time! April 2019 and salary with experience
Should we burninate the [wrap] tag?creating and submitting a form with javascriptCreate GUID / UUID in JavaScript?How do JavaScript closures work?What is the most efficient way to deep clone an object in JavaScript?How do I remove a property from a JavaScript object?Which equals operator (== vs ===) should be used in JavaScript comparisons?How do I include a JavaScript file in another JavaScript file?What does “use strict” do in JavaScript, and what is the reasoning behind it?How to check whether a string contains a substring in JavaScript?How do I remove a particular element from an array in JavaScript?For-each over an array in JavaScript?



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








-4















I have an assigment, I don't understand it as i'm beginner.



Create a javascript script which will modify the DOM of a web-page.
The script must add a form with 4 elements: name, email, message(textarea) and submit button. Each element must contain a label with its name. For example, name field is input type, you must create still from javascript a label named "Name", same for the others except submit button. Also, each laber must have a colour added from javascript(red, blue, yellow). When you click submit button, it must have an alert: "Are you sure you want to send this message?".



Thank you in advance.










share|improve this question
























  • show your code here

    – brk
    Mar 8 at 16:20











  • Possible duplicate of creating and submitting a form with javascript

    – Anderson Pimentel
    Mar 8 at 16:22






  • 2





    I'm pretty sure that you are not understanding the requirements of your assignment. forms, textarea and even submit are all HTML. Perhaps you need JavaScript to create the form, but you still need some HTML, if nothing else to create the blank page. If you need to create the form using JavaScript then look at developer.mozilla.org/en-US/docs/Web/API/Document/createElement

    – Jeremy J Starcher
    Mar 8 at 16:24

















-4















I have an assigment, I don't understand it as i'm beginner.



Create a javascript script which will modify the DOM of a web-page.
The script must add a form with 4 elements: name, email, message(textarea) and submit button. Each element must contain a label with its name. For example, name field is input type, you must create still from javascript a label named "Name", same for the others except submit button. Also, each laber must have a colour added from javascript(red, blue, yellow). When you click submit button, it must have an alert: "Are you sure you want to send this message?".



Thank you in advance.










share|improve this question
























  • show your code here

    – brk
    Mar 8 at 16:20











  • Possible duplicate of creating and submitting a form with javascript

    – Anderson Pimentel
    Mar 8 at 16:22






  • 2





    I'm pretty sure that you are not understanding the requirements of your assignment. forms, textarea and even submit are all HTML. Perhaps you need JavaScript to create the form, but you still need some HTML, if nothing else to create the blank page. If you need to create the form using JavaScript then look at developer.mozilla.org/en-US/docs/Web/API/Document/createElement

    – Jeremy J Starcher
    Mar 8 at 16:24













-4












-4








-4








I have an assigment, I don't understand it as i'm beginner.



Create a javascript script which will modify the DOM of a web-page.
The script must add a form with 4 elements: name, email, message(textarea) and submit button. Each element must contain a label with its name. For example, name field is input type, you must create still from javascript a label named "Name", same for the others except submit button. Also, each laber must have a colour added from javascript(red, blue, yellow). When you click submit button, it must have an alert: "Are you sure you want to send this message?".



Thank you in advance.










share|improve this question
















I have an assigment, I don't understand it as i'm beginner.



Create a javascript script which will modify the DOM of a web-page.
The script must add a form with 4 elements: name, email, message(textarea) and submit button. Each element must contain a label with its name. For example, name field is input type, you must create still from javascript a label named "Name", same for the others except submit button. Also, each laber must have a colour added from javascript(red, blue, yellow). When you click submit button, it must have an alert: "Are you sure you want to send this message?".



Thank you in advance.







javascript forms






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 8 at 17:09







Alexandru Salitrarovici

















asked Mar 8 at 16:20









Alexandru SalitraroviciAlexandru Salitrarovici

12




12












  • show your code here

    – brk
    Mar 8 at 16:20











  • Possible duplicate of creating and submitting a form with javascript

    – Anderson Pimentel
    Mar 8 at 16:22






  • 2





    I'm pretty sure that you are not understanding the requirements of your assignment. forms, textarea and even submit are all HTML. Perhaps you need JavaScript to create the form, but you still need some HTML, if nothing else to create the blank page. If you need to create the form using JavaScript then look at developer.mozilla.org/en-US/docs/Web/API/Document/createElement

    – Jeremy J Starcher
    Mar 8 at 16:24

















  • show your code here

    – brk
    Mar 8 at 16:20











  • Possible duplicate of creating and submitting a form with javascript

    – Anderson Pimentel
    Mar 8 at 16:22






  • 2





    I'm pretty sure that you are not understanding the requirements of your assignment. forms, textarea and even submit are all HTML. Perhaps you need JavaScript to create the form, but you still need some HTML, if nothing else to create the blank page. If you need to create the form using JavaScript then look at developer.mozilla.org/en-US/docs/Web/API/Document/createElement

    – Jeremy J Starcher
    Mar 8 at 16:24
















show your code here

– brk
Mar 8 at 16:20





show your code here

– brk
Mar 8 at 16:20













Possible duplicate of creating and submitting a form with javascript

– Anderson Pimentel
Mar 8 at 16:22





Possible duplicate of creating and submitting a form with javascript

– Anderson Pimentel
Mar 8 at 16:22




2




2





I'm pretty sure that you are not understanding the requirements of your assignment. forms, textarea and even submit are all HTML. Perhaps you need JavaScript to create the form, but you still need some HTML, if nothing else to create the blank page. If you need to create the form using JavaScript then look at developer.mozilla.org/en-US/docs/Web/API/Document/createElement

– Jeremy J Starcher
Mar 8 at 16:24





I'm pretty sure that you are not understanding the requirements of your assignment. forms, textarea and even submit are all HTML. Perhaps you need JavaScript to create the form, but you still need some HTML, if nothing else to create the blank page. If you need to create the form using JavaScript then look at developer.mozilla.org/en-US/docs/Web/API/Document/createElement

– Jeremy J Starcher
Mar 8 at 16:24












1 Answer
1






active

oldest

votes


















0















I need to use only Javascript for this and I can only find answers
that use HTML




Web applications use HTML to contain, render and display elements in the viewport (browser window).



Where do you intend to render the form and capture user input?



You can build the DOM structure using JavaScript alone, however, there will still be a HTML file, which will contain the HTML elements created using javascript.



Please provide clarity as to your desired goal and what type of application this is being used for.



My gut feeling, for simplicity, is that you will require to use HTML as your template file, and JavaScript for interactivity and manipulation of the HTML file.




The script must add a form with 4 elements: name, email, message(textarea) and submit button. Each element must contain a label with its name. For example, name field is input type, you must create still from javascript a label named "Name", same for the others except submit button. Also, each laber must have a colour added from javascript(red, blue, yellow). When you click submit button, it must have an alert: "Are you sure you want to send this message?". That's it.




This is a start, just to try to help you to understand the concepts.



I do, however, implore you to go and explore with confidence - you won't break anything, just give it a try!



I recommend you try taking a look at some of these articles, have a look at my (very rudimentary) code below, and feel free to ask any questions you have!



JS:-
W3 Schools JS and HTML reference



HTML:-
W3 Schools: HTML Forms
W3 Schools: Label Tag
W3 Schools: Text Area Tag (This has been left out of the solution on purpose - give it a try!!)






(function divContent() 
//Create a 'div' as a container for our form
var div = document.createElement('div');
// Perhaps you could style it later using this class??
div.className = 'row';
// I have used backticks to contain some more normal looking HTML for you to review, it's not complete though!!
div.innerHTML = `<form action="javascript:" onsubmit="alert('Your message here, or, run a function from your JavaScript file and do more stuff!!')">
<label for="name">Name:</label>
<input type="text" name="name" id="name" value="Mickey Mouse">
<br>
<label for="email">Email:</label>
<input type="text" name="email" id="email" value="mickey@mouse.co.uk">
<br><br>
<input type="submit" value="Submit">
</form> `
// Get the body of the document, and append our div containing the form to display it on page
document.getElementsByTagName('body')[0].appendChild(div);
());

<!DOCTYPE html>
<html>

<head>

<meta name="author" content="CoderYen | Wrangling with 0s & 1s Since The Eighties">

</head>

<body>

</body>

</html>








share|improve this answer

























  • I really don't understand either, I'm confused.. I will try to translate in english the assigment. It's basic stuff but I don't know I don't get it. Create a javascript script which will modify the DOM of a web-page.

    – Alexandru Salitrarovici
    Mar 8 at 16:47











  • The script must add a form with 4 elements: name, email, message(textarea) and submit button. Each element must contain a label with its name. For example, name field is input type, you must create still from javascript a label named "Name", same for the others except submit button. Also, each laber must have a colour added from javascript(red, blue, yellow). When you click submit button, it must have an alert: "Are you sure you want to send this message?". That's it.

    – Alexandru Salitrarovici
    Mar 8 at 16:47











  • Alexandru Salitrarovici - I implore you to go and explore, I've updated the response and will be happy to help give you a gentle steer where I can. Developing is a marathon, not a sprint - there are so many principles I cannot convey in a short focused response in this post. It's for that reason the question could be deemed a little too broad and vague, however, this is a community built to encourage the free sharing of learning and expression of technical expertise/exploration of these areas - at all levels! Wishing you all the best - happy learning :)

    – YenCoder
    Mar 8 at 21:37












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55067106%2fform-using-javascript-exclusively%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0















I need to use only Javascript for this and I can only find answers
that use HTML




Web applications use HTML to contain, render and display elements in the viewport (browser window).



Where do you intend to render the form and capture user input?



You can build the DOM structure using JavaScript alone, however, there will still be a HTML file, which will contain the HTML elements created using javascript.



Please provide clarity as to your desired goal and what type of application this is being used for.



My gut feeling, for simplicity, is that you will require to use HTML as your template file, and JavaScript for interactivity and manipulation of the HTML file.




The script must add a form with 4 elements: name, email, message(textarea) and submit button. Each element must contain a label with its name. For example, name field is input type, you must create still from javascript a label named "Name", same for the others except submit button. Also, each laber must have a colour added from javascript(red, blue, yellow). When you click submit button, it must have an alert: "Are you sure you want to send this message?". That's it.




This is a start, just to try to help you to understand the concepts.



I do, however, implore you to go and explore with confidence - you won't break anything, just give it a try!



I recommend you try taking a look at some of these articles, have a look at my (very rudimentary) code below, and feel free to ask any questions you have!



JS:-
W3 Schools JS and HTML reference



HTML:-
W3 Schools: HTML Forms
W3 Schools: Label Tag
W3 Schools: Text Area Tag (This has been left out of the solution on purpose - give it a try!!)






(function divContent() 
//Create a 'div' as a container for our form
var div = document.createElement('div');
// Perhaps you could style it later using this class??
div.className = 'row';
// I have used backticks to contain some more normal looking HTML for you to review, it's not complete though!!
div.innerHTML = `<form action="javascript:" onsubmit="alert('Your message here, or, run a function from your JavaScript file and do more stuff!!')">
<label for="name">Name:</label>
<input type="text" name="name" id="name" value="Mickey Mouse">
<br>
<label for="email">Email:</label>
<input type="text" name="email" id="email" value="mickey@mouse.co.uk">
<br><br>
<input type="submit" value="Submit">
</form> `
// Get the body of the document, and append our div containing the form to display it on page
document.getElementsByTagName('body')[0].appendChild(div);
());

<!DOCTYPE html>
<html>

<head>

<meta name="author" content="CoderYen | Wrangling with 0s & 1s Since The Eighties">

</head>

<body>

</body>

</html>








share|improve this answer

























  • I really don't understand either, I'm confused.. I will try to translate in english the assigment. It's basic stuff but I don't know I don't get it. Create a javascript script which will modify the DOM of a web-page.

    – Alexandru Salitrarovici
    Mar 8 at 16:47











  • The script must add a form with 4 elements: name, email, message(textarea) and submit button. Each element must contain a label with its name. For example, name field is input type, you must create still from javascript a label named "Name", same for the others except submit button. Also, each laber must have a colour added from javascript(red, blue, yellow). When you click submit button, it must have an alert: "Are you sure you want to send this message?". That's it.

    – Alexandru Salitrarovici
    Mar 8 at 16:47











  • Alexandru Salitrarovici - I implore you to go and explore, I've updated the response and will be happy to help give you a gentle steer where I can. Developing is a marathon, not a sprint - there are so many principles I cannot convey in a short focused response in this post. It's for that reason the question could be deemed a little too broad and vague, however, this is a community built to encourage the free sharing of learning and expression of technical expertise/exploration of these areas - at all levels! Wishing you all the best - happy learning :)

    – YenCoder
    Mar 8 at 21:37
















0















I need to use only Javascript for this and I can only find answers
that use HTML




Web applications use HTML to contain, render and display elements in the viewport (browser window).



Where do you intend to render the form and capture user input?



You can build the DOM structure using JavaScript alone, however, there will still be a HTML file, which will contain the HTML elements created using javascript.



Please provide clarity as to your desired goal and what type of application this is being used for.



My gut feeling, for simplicity, is that you will require to use HTML as your template file, and JavaScript for interactivity and manipulation of the HTML file.




The script must add a form with 4 elements: name, email, message(textarea) and submit button. Each element must contain a label with its name. For example, name field is input type, you must create still from javascript a label named "Name", same for the others except submit button. Also, each laber must have a colour added from javascript(red, blue, yellow). When you click submit button, it must have an alert: "Are you sure you want to send this message?". That's it.




This is a start, just to try to help you to understand the concepts.



I do, however, implore you to go and explore with confidence - you won't break anything, just give it a try!



I recommend you try taking a look at some of these articles, have a look at my (very rudimentary) code below, and feel free to ask any questions you have!



JS:-
W3 Schools JS and HTML reference



HTML:-
W3 Schools: HTML Forms
W3 Schools: Label Tag
W3 Schools: Text Area Tag (This has been left out of the solution on purpose - give it a try!!)






(function divContent() 
//Create a 'div' as a container for our form
var div = document.createElement('div');
// Perhaps you could style it later using this class??
div.className = 'row';
// I have used backticks to contain some more normal looking HTML for you to review, it's not complete though!!
div.innerHTML = `<form action="javascript:" onsubmit="alert('Your message here, or, run a function from your JavaScript file and do more stuff!!')">
<label for="name">Name:</label>
<input type="text" name="name" id="name" value="Mickey Mouse">
<br>
<label for="email">Email:</label>
<input type="text" name="email" id="email" value="mickey@mouse.co.uk">
<br><br>
<input type="submit" value="Submit">
</form> `
// Get the body of the document, and append our div containing the form to display it on page
document.getElementsByTagName('body')[0].appendChild(div);
());

<!DOCTYPE html>
<html>

<head>

<meta name="author" content="CoderYen | Wrangling with 0s & 1s Since The Eighties">

</head>

<body>

</body>

</html>








share|improve this answer

























  • I really don't understand either, I'm confused.. I will try to translate in english the assigment. It's basic stuff but I don't know I don't get it. Create a javascript script which will modify the DOM of a web-page.

    – Alexandru Salitrarovici
    Mar 8 at 16:47











  • The script must add a form with 4 elements: name, email, message(textarea) and submit button. Each element must contain a label with its name. For example, name field is input type, you must create still from javascript a label named "Name", same for the others except submit button. Also, each laber must have a colour added from javascript(red, blue, yellow). When you click submit button, it must have an alert: "Are you sure you want to send this message?". That's it.

    – Alexandru Salitrarovici
    Mar 8 at 16:47











  • Alexandru Salitrarovici - I implore you to go and explore, I've updated the response and will be happy to help give you a gentle steer where I can. Developing is a marathon, not a sprint - there are so many principles I cannot convey in a short focused response in this post. It's for that reason the question could be deemed a little too broad and vague, however, this is a community built to encourage the free sharing of learning and expression of technical expertise/exploration of these areas - at all levels! Wishing you all the best - happy learning :)

    – YenCoder
    Mar 8 at 21:37














0












0








0








I need to use only Javascript for this and I can only find answers
that use HTML




Web applications use HTML to contain, render and display elements in the viewport (browser window).



Where do you intend to render the form and capture user input?



You can build the DOM structure using JavaScript alone, however, there will still be a HTML file, which will contain the HTML elements created using javascript.



Please provide clarity as to your desired goal and what type of application this is being used for.



My gut feeling, for simplicity, is that you will require to use HTML as your template file, and JavaScript for interactivity and manipulation of the HTML file.




The script must add a form with 4 elements: name, email, message(textarea) and submit button. Each element must contain a label with its name. For example, name field is input type, you must create still from javascript a label named "Name", same for the others except submit button. Also, each laber must have a colour added from javascript(red, blue, yellow). When you click submit button, it must have an alert: "Are you sure you want to send this message?". That's it.




This is a start, just to try to help you to understand the concepts.



I do, however, implore you to go and explore with confidence - you won't break anything, just give it a try!



I recommend you try taking a look at some of these articles, have a look at my (very rudimentary) code below, and feel free to ask any questions you have!



JS:-
W3 Schools JS and HTML reference



HTML:-
W3 Schools: HTML Forms
W3 Schools: Label Tag
W3 Schools: Text Area Tag (This has been left out of the solution on purpose - give it a try!!)






(function divContent() 
//Create a 'div' as a container for our form
var div = document.createElement('div');
// Perhaps you could style it later using this class??
div.className = 'row';
// I have used backticks to contain some more normal looking HTML for you to review, it's not complete though!!
div.innerHTML = `<form action="javascript:" onsubmit="alert('Your message here, or, run a function from your JavaScript file and do more stuff!!')">
<label for="name">Name:</label>
<input type="text" name="name" id="name" value="Mickey Mouse">
<br>
<label for="email">Email:</label>
<input type="text" name="email" id="email" value="mickey@mouse.co.uk">
<br><br>
<input type="submit" value="Submit">
</form> `
// Get the body of the document, and append our div containing the form to display it on page
document.getElementsByTagName('body')[0].appendChild(div);
());

<!DOCTYPE html>
<html>

<head>

<meta name="author" content="CoderYen | Wrangling with 0s & 1s Since The Eighties">

</head>

<body>

</body>

</html>








share|improve this answer
















I need to use only Javascript for this and I can only find answers
that use HTML




Web applications use HTML to contain, render and display elements in the viewport (browser window).



Where do you intend to render the form and capture user input?



You can build the DOM structure using JavaScript alone, however, there will still be a HTML file, which will contain the HTML elements created using javascript.



Please provide clarity as to your desired goal and what type of application this is being used for.



My gut feeling, for simplicity, is that you will require to use HTML as your template file, and JavaScript for interactivity and manipulation of the HTML file.




The script must add a form with 4 elements: name, email, message(textarea) and submit button. Each element must contain a label with its name. For example, name field is input type, you must create still from javascript a label named "Name", same for the others except submit button. Also, each laber must have a colour added from javascript(red, blue, yellow). When you click submit button, it must have an alert: "Are you sure you want to send this message?". That's it.




This is a start, just to try to help you to understand the concepts.



I do, however, implore you to go and explore with confidence - you won't break anything, just give it a try!



I recommend you try taking a look at some of these articles, have a look at my (very rudimentary) code below, and feel free to ask any questions you have!



JS:-
W3 Schools JS and HTML reference



HTML:-
W3 Schools: HTML Forms
W3 Schools: Label Tag
W3 Schools: Text Area Tag (This has been left out of the solution on purpose - give it a try!!)






(function divContent() 
//Create a 'div' as a container for our form
var div = document.createElement('div');
// Perhaps you could style it later using this class??
div.className = 'row';
// I have used backticks to contain some more normal looking HTML for you to review, it's not complete though!!
div.innerHTML = `<form action="javascript:" onsubmit="alert('Your message here, or, run a function from your JavaScript file and do more stuff!!')">
<label for="name">Name:</label>
<input type="text" name="name" id="name" value="Mickey Mouse">
<br>
<label for="email">Email:</label>
<input type="text" name="email" id="email" value="mickey@mouse.co.uk">
<br><br>
<input type="submit" value="Submit">
</form> `
// Get the body of the document, and append our div containing the form to display it on page
document.getElementsByTagName('body')[0].appendChild(div);
());

<!DOCTYPE html>
<html>

<head>

<meta name="author" content="CoderYen | Wrangling with 0s & 1s Since The Eighties">

</head>

<body>

</body>

</html>








(function divContent() 
//Create a 'div' as a container for our form
var div = document.createElement('div');
// Perhaps you could style it later using this class??
div.className = 'row';
// I have used backticks to contain some more normal looking HTML for you to review, it's not complete though!!
div.innerHTML = `<form action="javascript:" onsubmit="alert('Your message here, or, run a function from your JavaScript file and do more stuff!!')">
<label for="name">Name:</label>
<input type="text" name="name" id="name" value="Mickey Mouse">
<br>
<label for="email">Email:</label>
<input type="text" name="email" id="email" value="mickey@mouse.co.uk">
<br><br>
<input type="submit" value="Submit">
</form> `
// Get the body of the document, and append our div containing the form to display it on page
document.getElementsByTagName('body')[0].appendChild(div);
());

<!DOCTYPE html>
<html>

<head>

<meta name="author" content="CoderYen | Wrangling with 0s & 1s Since The Eighties">

</head>

<body>

</body>

</html>





(function divContent() 
//Create a 'div' as a container for our form
var div = document.createElement('div');
// Perhaps you could style it later using this class??
div.className = 'row';
// I have used backticks to contain some more normal looking HTML for you to review, it's not complete though!!
div.innerHTML = `<form action="javascript:" onsubmit="alert('Your message here, or, run a function from your JavaScript file and do more stuff!!')">
<label for="name">Name:</label>
<input type="text" name="name" id="name" value="Mickey Mouse">
<br>
<label for="email">Email:</label>
<input type="text" name="email" id="email" value="mickey@mouse.co.uk">
<br><br>
<input type="submit" value="Submit">
</form> `
// Get the body of the document, and append our div containing the form to display it on page
document.getElementsByTagName('body')[0].appendChild(div);
());

<!DOCTYPE html>
<html>

<head>

<meta name="author" content="CoderYen | Wrangling with 0s & 1s Since The Eighties">

</head>

<body>

</body>

</html>






share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 8 at 21:31

























answered Mar 8 at 16:24









YenCoderYenCoder

94




94












  • I really don't understand either, I'm confused.. I will try to translate in english the assigment. It's basic stuff but I don't know I don't get it. Create a javascript script which will modify the DOM of a web-page.

    – Alexandru Salitrarovici
    Mar 8 at 16:47











  • The script must add a form with 4 elements: name, email, message(textarea) and submit button. Each element must contain a label with its name. For example, name field is input type, you must create still from javascript a label named "Name", same for the others except submit button. Also, each laber must have a colour added from javascript(red, blue, yellow). When you click submit button, it must have an alert: "Are you sure you want to send this message?". That's it.

    – Alexandru Salitrarovici
    Mar 8 at 16:47











  • Alexandru Salitrarovici - I implore you to go and explore, I've updated the response and will be happy to help give you a gentle steer where I can. Developing is a marathon, not a sprint - there are so many principles I cannot convey in a short focused response in this post. It's for that reason the question could be deemed a little too broad and vague, however, this is a community built to encourage the free sharing of learning and expression of technical expertise/exploration of these areas - at all levels! Wishing you all the best - happy learning :)

    – YenCoder
    Mar 8 at 21:37


















  • I really don't understand either, I'm confused.. I will try to translate in english the assigment. It's basic stuff but I don't know I don't get it. Create a javascript script which will modify the DOM of a web-page.

    – Alexandru Salitrarovici
    Mar 8 at 16:47











  • The script must add a form with 4 elements: name, email, message(textarea) and submit button. Each element must contain a label with its name. For example, name field is input type, you must create still from javascript a label named "Name", same for the others except submit button. Also, each laber must have a colour added from javascript(red, blue, yellow). When you click submit button, it must have an alert: "Are you sure you want to send this message?". That's it.

    – Alexandru Salitrarovici
    Mar 8 at 16:47











  • Alexandru Salitrarovici - I implore you to go and explore, I've updated the response and will be happy to help give you a gentle steer where I can. Developing is a marathon, not a sprint - there are so many principles I cannot convey in a short focused response in this post. It's for that reason the question could be deemed a little too broad and vague, however, this is a community built to encourage the free sharing of learning and expression of technical expertise/exploration of these areas - at all levels! Wishing you all the best - happy learning :)

    – YenCoder
    Mar 8 at 21:37

















I really don't understand either, I'm confused.. I will try to translate in english the assigment. It's basic stuff but I don't know I don't get it. Create a javascript script which will modify the DOM of a web-page.

– Alexandru Salitrarovici
Mar 8 at 16:47





I really don't understand either, I'm confused.. I will try to translate in english the assigment. It's basic stuff but I don't know I don't get it. Create a javascript script which will modify the DOM of a web-page.

– Alexandru Salitrarovici
Mar 8 at 16:47













The script must add a form with 4 elements: name, email, message(textarea) and submit button. Each element must contain a label with its name. For example, name field is input type, you must create still from javascript a label named "Name", same for the others except submit button. Also, each laber must have a colour added from javascript(red, blue, yellow). When you click submit button, it must have an alert: "Are you sure you want to send this message?". That's it.

– Alexandru Salitrarovici
Mar 8 at 16:47





The script must add a form with 4 elements: name, email, message(textarea) and submit button. Each element must contain a label with its name. For example, name field is input type, you must create still from javascript a label named "Name", same for the others except submit button. Also, each laber must have a colour added from javascript(red, blue, yellow). When you click submit button, it must have an alert: "Are you sure you want to send this message?". That's it.

– Alexandru Salitrarovici
Mar 8 at 16:47













Alexandru Salitrarovici - I implore you to go and explore, I've updated the response and will be happy to help give you a gentle steer where I can. Developing is a marathon, not a sprint - there are so many principles I cannot convey in a short focused response in this post. It's for that reason the question could be deemed a little too broad and vague, however, this is a community built to encourage the free sharing of learning and expression of technical expertise/exploration of these areas - at all levels! Wishing you all the best - happy learning :)

– YenCoder
Mar 8 at 21:37






Alexandru Salitrarovici - I implore you to go and explore, I've updated the response and will be happy to help give you a gentle steer where I can. Developing is a marathon, not a sprint - there are so many principles I cannot convey in a short focused response in this post. It's for that reason the question could be deemed a little too broad and vague, however, this is a community built to encourage the free sharing of learning and expression of technical expertise/exploration of these areas - at all levels! Wishing you all the best - happy learning :)

– YenCoder
Mar 8 at 21:37




















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55067106%2fform-using-javascript-exclusively%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

AWS Lex not identifying response if by a variable The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceEnforcing custom enumeration in AWS LEX for slot valuesHow to give response based on user response in Amazon Lex?Intercepting AWS Lambda Response to a AWS Lex QueryLex chat bot error: Reached second execution of fulfillment lambda on the same utteranceamazon lex showing invalid responseLambda response send back to Lex slot?Response card in Amazon lexAmazon Lex - Lambda response return HTML to botHow can I solve 424 (Failed Dependency) (python) obtained from Amazon lex?

Алба-Юлія

Захаров Федір Захарович