input value being passed

I have 2 divs on one page.  I have two input fields in the first div and a button. after you have enter the info you press a button and it hides that div and shows the next one. Inside this div I have a dropdown and the 2 hidden fields that I want to get the values from the 2 input fields from the first div.

<div id="welcome">
        <input type="text" id="loginnumber" name="Loginnumber" placeholder="Number" required="required">
        <br>
        <br>
        <input type="text" id="loginname" name="Loginname" placeholder="Name" required="required">
        <br>
        <br>
        <input type="image" src="button.jpg" alt="" class="login-welcome" />
</div>
<div id="form" style="display:none">
    <form name="login-form" method="post" id="login-form" autocomplete='off' action="<?php echo $action; ?>">
        <input type="hidden" name="number" id="number" value="">
        <input type="hidden" name="name" id="name" value="">
        <select>
            <option>1</option>
            <option>2</option>
            <option>3</option>
        </select>
        <br>
        <br>
        <input type="image" src="button.jpg" name="submit" alt="" class="connectButton" />
    </form>
</div>
<script type="text/javascript">
$(document).ready(function () {
    $('.login-welcome').click(function () {
        $("#welcome").hide();
        $("#form").show();
    });

    $('.connectButton').click(function () {
        $('#pack_list').hide();
        $('#progress').fadeIn();

        if ($('#login-form').valid()) {
            $('.connectButton').addClass('grey');
            $('.connectButton').fadeOut(function () {
                $('#form').hide();
            });
        }
    });
});
</script>

Open in new window

ucohockeyAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

Ray PaseurCommented:
This is the sort of thing that is perfect for AngularJS -- two-way data binding!
0
ucohockeyAuthor Commented:
I would like to do this without having to load anything, I looked at this solution and might work but would like to see it done using jquery if possible.
0
Ray PaseurCommented:
If you want to do this with jQuery, this snippet shows the general design pattern.
http://iconoun.com/demo/temp_ucohockey.php

<!DOCTYPE html>
<html dir="ltr" lang="en-US">
<head>
<meta charset="utf-8" />
<meta name="robots" content="noindex, nofollow" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<style type="text/css">
/* STYLE SHEET HERE */
</style>

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script>
$(document).ready(function(){
    $('#loginNumber').focus();
    $('#loginWelcome').click(function(){
        var myNumber = $("#loginNumber").val();
        $("#number").val(myNumber);
        $("#welcome").hide();
        $("#form").show();
    });

});
</script>

<title>HTML5 Page With jQuery in UTF-8 Encoding</title>
</head>
<body>

<noscript>Your browsing experience will be much better with JavaScript enabled!</noscript>

<div id="welcome">
Welcome, Enter a number:
        <input type="text" id="loginNumber" name="whatever" placeholder="Number" required="required" />
        <input type="submit" value="clickMe" id="loginWelcome" />
</div>

<div id="form" style="display:none">
Form
        <input type="text" name="number" id="number" value="" />
</div>

</body>
</html>

Open in new window

0
Ray PaseurCommented:
Either way you have to "load" something - either the AngularJS library or the jQuery library,  You could probably write your own native JavaScript but most of us would not do that today, since there are so many good frameworks out there.
0
Brian TaoSenior Business Solutions ConsultantCommented:
Just add 2 lines to your $('.login-welcome').click() call.  The resulted code then should look like this:
    $('.login-welcome').click(function () {
        $("#welcome").hide();
        $("#form").show();
        $("#number").val($("#loginnumber").val());
        $("#name").val($("#loginname").val());
    });

Open in new window

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
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
JavaScript

From novice to tech pro — start learning today.