Tuesday, February 28, 2017

Send data of form to div on submitting , outside the form using jQuery, laravel 5.3

this is my form

      <form method="post" action=""> 
      <input type="hidden" name="_token" value="">

      <label>First Name</label>
           <input type="text" name="firstname" placeholder="First Name" value="" >

      <label>Email Address</label>
          <input type="text" name="email" placeholder="Email Address"  value="" >

      <label>Phone Number <span> (optional)</span></label>
             <input type="text" name="phone" placeholder="(888) 888-888" value="" >

      <button id="hitme" class="submitBTN getstart" type="submit" onclick='return false;'> Get Started </button> 
       </form> 

this is div outside the form

   <div class="vgasRit">
        <p>SUMMARY</p>
           <div class="sfieldz w100">

              <label>Name:</label>
              <input type="text" placeholder="John Smith" value="">

          </div>
          <div class="w100">
              <label>Email Address:</label>
              <input type="text" placeholder="johnsmith@gmail.com" value="" >
           </div>

            <div class="w100">
               <label>Phone Number:</label>
            <input type="text" placeholder="(888) 888-888" value="">
             </div>
    </div>

I want to access the value of the "fistname" , "lastname" and "phone" as user submit the form,so that i can display it in summary div.

Note: i have tried compact function of php in my controller so that i can send the whole database object in my view but this solution not working , after using compact function i was access the object like this

    <input type="text" placeholder="John Smith"  value="<?= (!empty($group_data)) ? $group_data->firstname : '';?>">

Any ideas regarding this ? i am new to laravel. I have served several hours on internet but nothing found out.




via Learner

Advertisement