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 jQuery Basics (2014) Creating a Mobile Drop Down Menu Setting a value

ashique desai
ashique desai
3,662 Points

Using j Query select the input and show it in the "Full Name" box

"Need to store to store the name from the prompt dialog box and show it in the 'Full Name' Box."

I am not able to solve this j Query challenge even after trying out for more than an hour. Can any body help please!

js/app.js
```Javascript
//Show Prompt Window and store value
var fullName = prompt("What is your full name?");

//Select Input with the id of #fullName
var $select = $("<select></select>");
$("#fullName").append($select);
var $input = $select;

$("#fullName").each(function(){
  var $select = $(this);
  //Insert value in to full name input
  $input.val($select.attr("#fullName"));
  $input.text($select.text());
  $select.append($input);
  });
```index.html
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<label for="fullName">Full Name</label><input id="fullName" name="fullName" value="" disabled>
<script src="//code.jquery.com/jquery-1.11.0.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/app.js" type="text/javascript" charset="utf-8"></script>
</body>
</html>

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! I'm not sure if the code you've posted is from the challenge or not. But the challenge only requires one line of code. I'm not sure exactly what you've tried, so it's hard to say where you're going wrong. Here was my solution:

$("#fullName").val(fullName);

This selects the element with the id "fullName" and then uses the val method and passes in the value stored in the fullName variable. There may be some confusion here between the fullName variable and the element with the fullName ID. The value in the fullName variable is the value that was input into the prompt sent to the user.

Hope this helps! :sparkles:

ashique desai
ashique desai
3,662 Points

Thanks a lot Jennifer, that worked!