对于JavaScript来说还是一个新手,如果这很明显就道歉,但我无法在这里找到答案。
我正在尝试根据下拉选项的值单击提交按钮时重定向。
<html>
<body>
<h1>test</h1>
<select id="eventChoice" style="width:35vw;">
<option value="theatre">Theatre</option>
<option value="comedy">Comedy</option>
<option value="music">Music</option>
<option value="open mic">Open Mic</option>
</select>
<button id="eventSubmit">Submit</button>
<script type="text/javascript">
var submit = document.getElementById('eventSubmit');
var choice = document.getElementById('eventChoice');
submit.onClick function(){
if (choice.selectedIndex == "Comedy"){
location.href="http://google.com";
}
}
</script>
</body>
</html>
&#13;
任何帮助都会很棒。奇怪的是,我可以在jQuery中做到这一点,但我想尽可能多地学习javascript。
答案 0 :(得分:3)
@Tom Bird:语法错误。
您可以像这样修改它,它应该可以工作。
create materialized view as
select t1.serial serial, t1.type type, t1.kind kind from t1
union
select t2.id, t2.model, t2.product from t2
union
select t3.serialno, t3.typeof, t3.ci_product from t3;
答案 1 :(得分:1)
试试这个:
if ($request->hasFile('featured_image')) {
$realname = pathinfo($request->file('featured_image')->getClientOriginalName(), PATHINFO_FILENAME);
$extension = $request->file('featured_image')->getClientOriginalExtension();
$new_name = $realname."-".time().".".$extension;
$request->file('featured_image')->storeAs('public/uploads',$new_name);
$path = Storage::url('uploads/'.$new_name);
$post->featured_image = $path;
Image::make($path)->resize(320, 240)->insert($path);
}
&#13;
var submit = document.getElementById('eventSubmit');
var choice = document.getElementById('eventChoice');
submit.onclick = function(){
var choiceselected = choice[choice.selectedIndex].text;
if (choiceselected === "Comedy"){
window.location.href="http://google.com";
}
};
&#13;
答案 2 :(得分:0)
<html>
<body>
<h1 id="selectedOption">test</h1>
<select id="eventChoice" style="width:35vw;">
<option value="theatre">Theatre</option>
<option value="comedy">Comedy</option>
<option value="music">Music</option>
<option value="open mic">Open Mic</option>
</select>
<button id="eventSubmit">Submit</button>
<script type="text/javascript">
var submit = document.getElementById('eventSubmit');
var choice = document.getElementById('eventChoice');
var selectedOption= document.getElementById('selectedOption');
submit.onclick =(function(){
selectedOption.append(" "+choice[choice.selectedIndex].value);
if (choice[choice.selectedIndex].value == "comedy"){
window.location ="http://google.com";
}
});
</script>
</body>
</html>