-1

I need your help.

How can I make a function to check and see if a single or combination of selections has been made in any of the 3 boxes and alert me back with any of the resultant combination of messages below:

if a single selection has been made in any of the 3 dropdown boxes: "searching the database by [selectbox] only"

if a selection has been made in any 2 drop down boxes "searching the database by [selectbox] and [selectbox]

if a selection has been made in all 3 drop down boxes "searching the database by [selectbox], [selectbox], and [selectbox]

here is the setup:

<!DOCTYPE html>

<html>

<head>

</head>

<body>
Firtsname (x)<br>
    <select id="firstname">
        <option value=""></option>
        <option value="John">John</option>
        <option value="Jacob">Jacob</option>
        <option value="Nancy">Nancy</option>
        <option value="Loretta">Loretta</option>
    </select>
<br>
Lastname (y)<br>
    <select id="lastnname">
        <option value=""></option>
        <option value="Pearson">Pearson</option>
        <option value="Black">Black</option>
        <option value="Scott">Scott</option>
        <option value="Murray">Murray</option>
    </select>
    <br>
Age (z)<br>
    <select id="age">
        <option value=""></option>
        <option value="30">30</option>
        <option value="25">25</option>
        <option value="45">45</option>
        <option value="39">39</option>
    </select>
<br>
<br>
<input type="button" value="testit">
</body>

</html>
4

1 回答 1

0

读取选择选项值

$('#selectId').val();

设置选择选项值

$('#selectId').val('newValue');

阅读选定的文本

$('#selectId>option:selected').text();

在#selectId 中,输入您的 html 元素的 id,您应该没问题!

于 2013-09-13T14:57:37.483 回答