duanmibei1929 2018-11-24 00:10
浏览 48

通过动画形式获取数据到PHP?

So I have the following animated form in my HTML code.

<form id="formElem" name="formElem" action="" method="post">
                        <fieldset class="step">
                            <legend>Consultation</legend>
                            <p>
                                <input class = "consultation" type="submit" value="General Consultation">
                            </p>
                            <p>
                                <input class = "consultation" type="submit" value="Blood Test with Consultation">
                            </p>
                            <p>
                                <input class = "consultation" type="submit" value="Full Sexual Health Screen">
                            </p>
                             <p>
                                <input class = "consultation" type="submit" value="Hair Loss PRP Treatment">
                            </p>
                             <p>
                                <input class = "consultation" type="submit" value="Executive Health Screening">
                            </p>
                             <p>
                                <input class = "consultation" type="submit" value="Flu Vaccination">
                            </p>
                            <p>
                                <input class = "consultation" type="submit" value="Other">
                            </p>

                                <input type="hidden" name="consultation" id="consultation" value="">
                        </fieldset>

                        <fieldset class="step">
                            <legend>Provider</legend>
                             <p>
                                <input class = "provider" type="submit" value="Dr. Kevin O'Connell">
                            </p>
                             <p>
                                <input class = "provider" type="submit" value="Dr. Rachel Fitxgerald">
                            </p>
                             <p>
                                <input class = "provider" type="submit" value="Dr. Simon Gilmore">
                            </p>
                            <p>
                                <input class = "provider" type="submit" value="Nurse Julie Byrne">
                            </p>

                                <input type="hidden" name="provider" id="provider" value="">
                        </fieldset>
                        <fieldset class="step">
                            <legend>Date</legend>
                            <p>
                                <input type="date" name="date">
                            </p>
                             <p class="submit">
                                <button id="registerButton" type="submit">Confirm</button>
                            </p>
                        </fieldset>

                        <fieldset class="step">
                            <legend>Confirm</legend>
                            <p>
                                Thank you for requesting an appointment. We will be in touch with you shortly to confirm it.
                            </p>
                            <p class="submit">
                                <button id="registerButton"type="submit">Home</button>
                            </p>
                        </fieldset>
                    </form>

As you can see each element is a clickable one then it brings you to the next part of the form. My goal is to, when submitted, have each of the elements the user clicked on be sent to the action page via php and using $_POST. I have tried using jQuery for this and detecting when an element is clicked, transferring that value to a hidden input and retrieving the data from that but I can't seem to get it right.

$('input.consultation').click(function(){
  $(this).text() = consultation_value;
  $('#consultation').text() = consultation_value;
  console.log(consultation_value);
});

$('input.provider').click(function(){
  $(this).text() = provider_value;
  $('#provider').text() = provider_value;
  console.log(provider_value);
});

If anyone could help me learn why my code isn't working or offer a more efficient solution I'd appreciate it

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 stm32开发clion时遇到的编译问题
    • ¥15 lna设计 源简并电感型共源放大器