Throw value of Data-Id of Input Element into a Textbox in jQuery

Here is the button which will open Modal Window
 <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Select Icon</button>

Open in new window


Here is the TEXTBOX
  <input type="textbox" id="txtcode" name="txtcode">

Open in new window


And this is the Modal Window Code

<div id="myModal" class="modal fade">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">Select Icon Code</h4>
            </div>
            <div class="modal-body">

              <input class="btn btn-xs btn-flat inputs" value="Icon1" type="button" data-toggle="modal" data-id="icon1" data-target="#myModal"/>
              <input class="btn btn-xs btn-flat inputs" value="Icon2" type="button" data-toggle="modal" data-id="icon2" data-target="#myModal"/>
              <input class="btn btn-xs btn-flat inputs" value="Icon3" type="button" data-toggle="modal" data-id="icon3" data-target="#myModal"/>
              <input class="btn btn-xs btn-flat inputs" value="Icon4" type="button" data-toggle="modal" data-id="icon4" data-target="#myModal"/>
              <input class="btn btn-xs btn-flat inputs" value="Icon5" type="button" data-toggle="modal" data-id="icon5" data-target="#myModal"/>


            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
                <!--button type="button" class="btn btn-primary">OK</button-->
            </div>
        </div>
    </div>
</div>

Open in new window


The Modal window will show a list of icons.  


And Here is the JS
<script type="text/javascript">

$(".inputs").click(function (e) {
    alert($(this).attr("data-id"));
});


</script>

Open in new window


I want when user click on any icon button, then its 'data-id' value will be copied to the textbox.
How is it possible?
Shano KhanSoftware EngineerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Shano KhanSoftware EngineerAuthor Commented:
its done.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Shano KhanSoftware EngineerAuthor Commented:
i do it myself
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.