on 05-31-2005 10:07 PM
Hi, I have created a DropdownList box using the following code:
<tr>
<td>
<hbj:dropdownListBox
id="ORGANIZATION"
selection=" ">
<hbj:listBoxItem key=" " value=" " />
<hbj:listBoxItem key="Marketing" value="Marketing" />
<hbj:listBoxItem key="Finance" value="Finance" />
<hbj:listBoxItem key="IT" value="IT" />
</hbj:dropdownListBox>
</td>
</tr>
By default, the selection in the Dropdownlist box is blank. The user will select one of the 3 departments mentioned above. However, if the user does not select any of the 3 departments, he should be prompted to do so. This should happen before the user clicks on the "Send" button which emails the form. Can anyone please help me? Thanks.
Hi Sri,
You can add an onClientClick to your send button and evaluate the value in the drop down box. Something like the following should work.
function CheckForm() {
var funcName = htmlb_formid+"_getHtmlbElementId";
func = window[funcName];
var dropDownValue = eval(func("ORGANIZATION"));
if (dropDownValue.getValue() == " ") {
alert("You must select from the drop down box!");
htmlbevent.cancelSubmit=true;
return false; }
else { return true; }
}
then your drop down like such:
<tr>
<td>
<hbj:dropdownListBox
id="ORGANIZATION"
selection=" "
jsObjectNeeded="true">
<hbj:listBoxItem key=" " value=" " />
<hbj:listBoxItem key="Marketing" value="Marketing" />
<hbj:listBoxItem key="Finance" value="Finance" />
<hbj:listBoxItem key="IT" value="IT" />
</hbj:dropdownListBox>
</td>
</tr>
To recap, your javaScript function should return false if the user has not selected a value. Also, please remember to add the parameter jsObjectNeeded="true" to your ORGANIZATION dropdown list so you can reference it from javaScript. Your button should have an onClientClick="CheckForm" as well.
Hope this helps.
Marty
FYI: Also discussed here:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.