Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
353 views
in Technique[技术] by (71.8m points)

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

<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());
});

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...