Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

how to post a url to a page with a submit button using javascript. i need step by step instructions.

please write the source code so i i can see what i did wrong heres my source code whats missing.

<html> <head> <title>Products </title>

</head> <body bgcolor="silver" Align="center"> <h1 style="color:blue";> Products</h1> <hr> <a href="Products.html">Products|</a> <a href="index.html">Back to home|</a> <a href="Advertise.html">Advertise|</a> <a href="About.html">About|</a> <hr> <form method="post" action="Product.html"> <br><br><br><br><br><br><pre><input type="url" id="url" name="url"> <button>submit</button> <script> function post url(){ var post= url document.getElementId.form(); } post url(); function sumbit button(){ var submit=submit button onsubmitbutton= post on submit button.show.onclick(); } submit button(); </script> </body> </html>

2 Answers

Steven Parker
Steven Parker
243,318 Points

It's not clear what you intended the script code to do here, but a script isn't necessary at all just to submit a form. Use a submit input to create the button:

    <input type=submit value=submit>

Pressing the button should submit the form with no JavaScript needed.

You might also find the course on HTML Forms helpful.

Don't know if this helps but in your code you have six opening <br> tags and you don't close any of them

Steven Parker
Steven Parker
243,318 Points

The "<br>" element is one of the few that do not have an end tag. The start tag by itself is correct.
See the MDN page for more information.

Sorry, mind was somewhere else I guess!