从dropdown html获取月份以显示在工具提示上

时间:2016-11-03 07:19:21

标签: javascript php html tooltip monthcalendar

如何使用id =“abc”将下拉月份和年份值传递给工具提示?我已将下拉月份和年份值传递给myFunction(),现在我想将其传递给工具提示

<form id="monthcurrent" method="post">
<!-- Select Year from drop down menu -->
<select class="selectpicker" id="selectyear" onchange="myFunction()">
<option value="<?php echo date('Y', strtotime('0 year')) ?>"><?php echo date('Y', strtotime('0 year')) ?></option>
<option value="<?php echo date('Y', strtotime('-1 year')) ?>"><?php echo date('Y', strtotime('-1 year')) ?></option>
<option value="<?php echo date('Y', strtotime('-2 year')) ?>"><?php echo date('Y', strtotime('-2 year')) ?></option>
<option value="<?php echo date('Y', strtotime('-3 year')) ?>"><?php echo date('Y', strtotime('-3 year')) ?></option>
<option value="<?php echo date('Y', strtotime('-4 year')) ?>"><?php echo date('Y', strtotime('-4 year')) ?></option>
<option value="<?php echo date('Y', strtotime('-5 year')) ?>"><?php echo date('Y', strtotime('-5 year')) ?></option>
<option value="<?php echo date('Y', strtotime('-6 year')) ?>"><?php echo date('Y', strtotime('-6 year')) ?></option>
<option value="<?php echo date('Y', strtotime('-7 year')) ?>"><?php echo date('Y', strtotime('-7 year'))?></option>
<option value="<?php echo date('Y', strtotime('-8 year')) ?>"><?php echo date('Y', strtotime('-8 year')) ?> </option>
<option value="<?php echo date('Y', strtotime('-9 year')) ?>"><?php echo date('Y', strtotime('-9 year')) ?> </option>
<option value="<?php echo date('Y', strtotime('-10 year')) ?>"><?php echo date('Y', strtotime('-10 year')) ?> </option>
<option value="<?php echo date('Y', strtotime('-11 year')) ?>"><?php echo date('Y', strtotime('-11 year')) ?> </option>
</select>
<!-- Select month from drop down menu -->
<select class="selectpicker" id="selectmonth" onchange="myFunction()">
<option value="<?php echo date('m', strtotime('-1 month')) ?>"><?php echo date('F', strtotime('-1 month')) ?></option>
<option value="<?php echo date('m', strtotime('-2 month')) ?>"><?php echo date('F', strtotime('-2 month')) ?></option>
<option value="<?php echo date('m', strtotime('-3 month')) ?>"><?php echo date('F', strtotime('-3 month')) ?></option>
<option value="<?php echo date('m', strtotime('-4 month')) ?>"><?php echo date('F', strtotime('-4 month')) ?></option>
<option value="<?php echo date('m', strtotime('-5 month')) ?>"><?php echo date('F', strtotime('-5 month')) ?></option>
<option value="<?php echo date('m', strtotime('-6 month')) ?>"><?php echo date('F', strtotime('-6 month')) ?></option>
<option value="<?php echo date('m', strtotime('-7 month')) ?>"><?php echo date('F', strtotime('-7 month')) ?></option>
<option value="<?php echo date('m', strtotime('-8 month')) ?>"><?php echo date('F', strtotime('-8 month'))?></option>
<option value="<?php echo date('m', strtotime('-9 month')) ?>"><?php echo date('F', strtotime('-9 month')) ?> </option>
<option value="<?php echo date('m', strtotime('-10 month')) ?>"><?php echo date('F', strtotime('-10 month')) ?> </option>
<option value="<?php echo date('m', strtotime('-11 month')) ?>"><?php echo date('F', strtotime('-11 month')) ?> </option>
<option value="<?php echo date('m', strtotime('-12 month')) ?>"><?php echo date('F', strtotime('-12 month')) ?> </option>
</select>
<!-- Submit Button -->
<input name="submit" class="btn btn-warning" type="submit" value="submit">
</form>

<font size="45px" id="abc" data-toggle="tooltip">
<script>
function myFunction() {
var month = ["January","February","March","April","May","June","July","August","September","October","November","December"]
var x = document.getElementById("selectmonth").value;
var y = document.getElementById("selectyear").value;

document.getElementById("abc").innerHTML = "Quick summary for " + month[x - 1] + " " + y ;}
</script>

0 个答案:

没有答案