Как запомнить значения формы ввода? - PullRequest
0 голосов
/ 27 октября 2010

Я пытаюсь создать 2 формы, которые пользователь может выбрать, нажав form1 и formt2.

Когда пользователь выбирает между form1 и form2.Я хочу, чтобы form2 запомнил значение form1 и передал значение выбранной формы для отправки

Как это можно сделать самым простым способом?

Спасибо

1 Ответ

0 голосов
/ 27 октября 2010

Как насчет использования одних и тех же входов для похожих записей?

Вы можете использовать классы CSS, чтобы скрыть элементы / метки, которые вы не хотите видеть.

<script type="text/javascript">
$(document).ready(function() {
    $('.form-select').change(function() {
        // changes the class of our form
        var setClass = "mode" + $('input[name=whichForm]:radio:checked').val();
        $('#theForm').attr('class',setClass);
    });
});
</script>

<style type="text/css">
    #theForm fieldset { display: inline; }       // just a visual preference
    #theForm .business { color: blue; }          // color-coding
    #theForm .personal { color: green; }         // more color-coding
    #theForm.mode1 .business { display: none; }  // hides .business items when not needed
    #theForm.mode2 .personal { display: none; }  // hides .personal items when not needed
</style>

<form id="theForm" class="mode3" action="take-form.php">
    <fieldset>
        <legend> Information </legend>
        <input type="radio" id="whichForm-1" class="form-select" name="whichForm" value="1"><label for="whichForm-1">Personal</label>
        <input type="radio" id="whichForm-2" class="form-select" name="whichForm" value="2"><label for="whichForm-2">Business</label>
        <input type="radio" id="whichForm-3" class="form-select" name="whichForm" value="3"><label for="whichForm-3">Show All (Debug)</label>
        <hr>
        <input type="text" id="name" name="name">
        <label for="name">
                <span class="personal">Your</span>
                <span class="business">Business</span>
                <span> Name</span>
        </label>
        <br>
        <input type="text" id="address" name="address">
        <label for="address">
            <span class="personal">Home</span>
            <span class="business">Office</span>
            <span> Address</span>
        </label>
    </fieldset>
</form>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...