动态更改表单操作URL

时间:2015-02-06 22:39:46

标签: javascript php jquery html

所以我需要将默认网址更改为更好的我已经使它工作.htaccess但是我无法将其用于表单操作...有人可以告诉我如何更改表单url表单转到网址

s=thesearch&for=for&genre=genre&lang=lang&quality=quality&rating=rating&orderby=orderby

我想让表单转到

s=thesearch/for/genre/lang/quality/rating/orderby

进入第一个网址的表单代码:

<form role="search" method="get" class="search-form" action="s=">
    <label>
        <input autofocus autocomplete="off" type="search" class="search-field" placeholder="Search …" value="" name="" title="Search for:">
    </label>
    <input type="submit" class="search-submit" value="Search">
    <!-- Squared THREE -->
<div class="squaredThree">
    <input  type="checkbox" id="squaredThree" name="check" />
    <label for="squaredThree">
    <div style="font-weight: 700;font-size: 1.1em;color: #5a5a5a;margin-left:25px;margin-top:2px;">Advanced</div>
    <div style="font-weight: 700;font-size: 1.1em;color: #5a5a5a;margin-left:98px;margin-top:-20px;">Search</div></label>
</div>
<script type="text/javascript">

document.getElementById('squaredThree').onchange = function() {
    document.getElementById('advanced-search').style.display = this.checked ? 'block' : 'none';
};
</script>
    <div id="advanced-search">
    <span style="font-weight: 700;font-size: 1.2em;color: #5a5a5a;margin-left:70px;">
    Search For:
    </span>
    <select name="for" style="margin-left:46px;">
    <option value="Title" selected="selected">Title</option>
    <option value="Actor">Actor</option>
    <option value="Writer">Writer</option>
    <option value="Director">Director</option>
    <option value="Company">Company</option>
    <option value="IMDb_ID">IMDb ID</option>
    </select><br>
    <span style="font-weight: 700;font-size: 1.2em;color: #5a5a5a;margin-left:85px;">
    Genre:
    </span>
    <select name="genre" style="margin-left:46px;">
    <option value="All" selected="selected">All</option>
    <option value="Action">Action</option>
    <option value="Adventure">Adventure</option>
    <option value="Animation">Animation</option>
    <option value="Comedy">Comedy</option>
    <option value="Crime">Crime</option>
    <option value="Drama">Drama</option>
    <option value="Family">Family</option>
    <option value="Fantasy">Fantasy</option>
    <option value="Horror">Horror</option>
    <option value="Music">Music</option>
    <option value="Musical">Musical</option>
    <option value="Mystery">Mystery</option>
    <option value="Romance">Romance</option>
    <option value="Sci-Fi">Sci-Fi</option>
    <option value="Sport">Sport</option>
    <option value="Thriller">Thriller</option>
    <option value="War">War</option>
    <option value="Western">Western</option></select>
    <span style="font-weight: 700;font-size: 1.2em;color: #5a5a5a;margin-left:82px;">Subtitle:</span>

    <select name="lang" style="margin-left:46px;">
    <option value="All" selected="selected">All</option>
    <option value="Arabic">Arabic</option>
    <option value="Czech">Czech</option>
    <option value="Danish">Danish</option>
    <option value="Dutch">Dutch</option>
    <option value="English">English</option>
    <option value="French">French</option>
    <option value="German">German</option>
    <option value="Greek">Greek</option>
    <option value="Indonesian">Indonesian</option>
    <option value="Malay">Malay</option>
    <option value="Spanish">Spanish</option>
    <option value="Swedish">Swedish</option>
    <option value="Turkish">Turkish</option>
</select>
<span style="font-weight: 700;font-size: 1.2em;color: #5a5a5a;margin-left:82.5px;">Quality:</span>
<select name="quality" style="margin-left:46px;">
<option value="All" selected="selected">All</option>
<option value="CAM">CAM</option>
<option value="Non-HD">Non HD</option>
<option value="HD">HD</option>
<option value="Full-HD">Full HD</option></select>

<span style="font-weight: 700;font-size: 1.2em;color: #5a5a5a;margin-left:85px;">Rating:</span>
<select name="rating" style="margin-left:46px;">
<option value="0" selected="selected">All</option>
<option value="9">9+</option>
<option value="8">8+</option>
<option value="7">7+</option>
<option value="6">6+</option>
<option value="5">5+</option>
<option value="4">4+</option>
<option value="3">3+</option>
<option value="2">2+</option>
<option value="1">1+</option>
</select><br>
<span style="font-weight: 700;font-size: 1.2em;color: #5a5a5a;margin-left:76px;">Order By:</span>
<select name="orderby" style="margin-left:46px;">
<option value="Latest" selected="selected">Latest</option>
<option value="Oldest">Oldest</option>
<option value="Rating">Rating</option>
<option value="Alphabetical">Alphabetical</option>
<option value="Views">Views</option></select>
</select>
</div>
</form>

任何知道如何更改表单网址的人......

1 个答案:

答案 0 :(得分:0)

您可以像任何其他属性一样设置动作属性

$("form").attr("action", "/path/to/formaction");