Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ul in the form not sending to the $_POST

I have this ul in my form

<form action="step1/" method="post" enctype="multipart/form-data" id="form">
    <div class="tabs">
        <ul>
            <li class="dot clicked radio_buttons"></li>
            <li class="active not_the_dot"><span class="l"></span><a href="#">Standard Class</a><span class="r"></span></li>
            <li class="dot radio_buttons"></li><li class="not_the_dot"><span class="l"></span><a href="#">Business Class</a><span class="r"></span></li>
            <li class="dot radio_buttons"></li><li class="not_the_dot"><span class="l"></span><a href="#">Premium</a><span class="r"></span></li>
        </ul>
....
....
....

and then i have other items in the form as well like

 <select name="quantity_id" class="quantity_select">
            <option selected="selected" value="0">SELCT STATION QUANTITY</option>
            <option value="1">1 Station</option>
            <option value="2">2 Station</option>
            <option value="3">3 Station</option>
            <option value="4">4 Station</option>
            <option value="5">5 Station</option>
    </select>

and on the form submit the quantity_id is present but the ul value is not ....is there something i need to change to make this value available....basically i need the "active" class text like Standard, business

like image 257
Matt Elhotiby Avatar asked Dec 12 '22 13:12

Matt Elhotiby


2 Answers

<ul/> items are not form elements and will not be posted when the form is submitted. If you need to capture these values you can store them in a hidden form element.

Example to capture the text into a hidden field, add a hidden field.

<input type="hidden" id="activeThing" name="activeThing"/>

And bind a click event to the li:

$("ul li.not_the_dot").click(function(){
  $("#activeThing").val($(this).find("a").text());
});
like image 82
Mark Coleman Avatar answered Dec 15 '22 04:12

Mark Coleman


html form only submits only value of its input(element like input, textarea, select) tags to server in params.

so if you want to send something to the sever make it an input element. If you have some predefine variable or values to send to the server use hidden fields for it.

like image 31
Naren Sisodiya Avatar answered Dec 15 '22 03:12

Naren Sisodiya