我正在尋找動態更改價格和id的值,並在後續錨鏈接中選擇不同的下拉菜單。比如如果我選擇3天,則價格將變爲24,並使用新的oID更改爲錨點和ID。在錨鏈接中動態更改值
注意:隱藏字段用於在數據庫中提交數據。 $_post['deadline']
。是的,糾正網址。輸入錯誤。
<a class="btn btn-warning" href="https://example.com?price=38&id=DS123">order</a>
HTML
<div class="col-sm-6">
<label for="price" class="control-lable">Urgency*:</label>
<select class="form-control" name="price" id="price" onchange="func()" required>
<option value="">Select urgency</option>
<option value="24">3 Days</option>
<option value="38">5 Days</option>
<option value="62">7 Days</option>
</select>
</div>
<input type="hidden" name="deadline" id="deadline" value="" />
<input type="hidden" name="oid" id="oid" value="" />
的Javascript
function func() {
var option = $("#price").val();
var dLine = $('#deadline').val();
var mID = new Date().getTime();
var oID = 'Q'+Math.round(mID/1000)
if (option =='24') {
dLine = 3 Days;
oID;
}
if (option =='38') {
dLine = 5 Days;
oID;
}
if (option =='62') {
dLine = 7 Days;
oID;
}
};
那麼如何處理隱藏字段呢? –
我想你忘了包括?在.com https://example.com&price=38&id=DS123應更改爲https://example.com?price=38&id=DS123 –