It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

Alert message is generating in all the fields.

Alert message is generating in all the fields.

Postby Santanu on Mon Aug 11, 2008 1:03 pm

I was working with an issue but could not figure it out. I need your help on this issue. I have a jsp file which shows Name field, Type drop down and Supervision Time Drop down. In original code when we select "Please select a Type" from the Drop down list and click on "Save" Button the pop up displays "Please select a Device Type" in the browser. I have to show some pop up message for oher type from the "Type" drop down list.

Now the issue occuring is when I put a else condition for the other type for "Type" drop down list and generate any message (for example: "You have selected other Type"), this alert message is generating in every field of this page. But I don't want this alert message in every field. I need it only for the other Type form the "Type" drop down list.

There is a validate() method in this JSP which generate these alert messages.

I am looking for your your suggession to generate the alert message only for the other type of "Type" drop down list.


function validate()
{
if ( true == containsInvalidCharacter( 'Name', document.formSettings.name.value ) )
{
return false;
}

if ( null != document.formSettings.superTm )
{
var superTm = document.formSettings.superTm.value;
if ( true == document.formSettings.supervision.checked && ( -1 > superTm || superTm > 129600 ) )
{
alert( "Please select 1 <= Supervision Time <= 129600" );
return false;
}

var voldSuperTm = <%=oldSuperTm%>;
if ( voldSuperTm != superTm && -1 != voldSuperTm )
{
var scs = parseInt( voldSuperTm / 3 );
var hrs = parseInt( scs >= 3600 ? (scs / 3600) : 0 );
var mns = parseInt( scs >= 60 ? ((scs - (3600 * hrs)) / 60) : 0 );
scs -= ((3600 * hrs) + (60 * mns));
var msg = "";
if ( 0 != hrs )
{
msg += hrs + " hour(s) ";
}
if ( 0 != mns )
{
msg += mns + " minute(s) ";
}
if ( 0 != scs )
{
msg += scs + " second(s) ";
}
alert( "It may take " + msg + "for supervision time to change.");
}
}

if ( null != document.formSettings.type.options )
{
var selectedTypeOption = document.formSettings.type.selectedIndex;
var selectedTypeValue = document.formSettings.type.options[selectedTypeOption].value;
if ( selectedTypeValue == "none" )
{
alert( "Please select a device type" );

}
else
{
alert( "You have selected other Type" );
}
}
return true;
}
Santanu
 
Posts: 16
Joined: Sat Aug 09, 2008 5:20 pm

Postby rangana on Tue Aug 12, 2008 1:05 am

Please include the related markups (HTML).
User avatar
rangana
500+ Club
 
Posts: 935
Joined: Wed Feb 27, 2008 5:14 am
Location: Cebu City Philippines

Alert message is generating in all the fields.

Postby Santanu on Wed Aug 13, 2008 8:35 pm

Here is the related HTML code for the Validate() method:

<body onkeypress="KeyPress();" onLoad="do_onLoad();">
<form name="formSettings" method="post"
action="./servlet/WardenConfigController">
<input type="hidden" name="wardenAction" value="">
<input type="hidden" name="<%=Device.ID%>" value="<%=theDevice.getGUID()%>">
<input type="hidden" name="<%=Device.ROOMID%>" value="<%=theDevice.getRoomID()%>">
<input type="hidden" name="<%=Device.IgnoreQRTXShiftGUID%>" value="<%=ignoreShiftGUID%>">
<input type="hidden" name="<%=Device.SysID%>" value="<%=theDevice.getSysID()%>">
<input type="hidden" name="tagid" value="<%=tagID%>">
<input type="hidden" name="nextGuid" value="">
<table class="main" border="0" cellspacing="0" cellpadding="0">
<jsp:include page="begin.jsp">
<jsp:param name="title" value="<%=TITLE%>" />
</jsp:include>

<!-- a row with the body of the page -->
<tr>
<td>
<table height="100%" width="100%" border="0" cellspacing="0"
cellpadding="0">
<tr>
<!-- the navigation column : hard-coded width of 160 pixels -->
<td class="nav-column">
<br>
<%=ConfigNavigator.getInstance().HtmlNavigation( "devices" )%>
</td>

<% if ( null != theDevice.getGUID() )
{ %>
<td class="main-column">
<!-- the main content column -->
<table width="100%" border="0" cellspacing="0" cellpadding="0"
bgcolor="#EFEFEF">

<tr>
<td align="center">
<table width="90%" border="1" cellspacing="0"
cellpadding="1">
<tr>
<td class="input-style-3">
<div align="left">
Device Configuration
</div>
</td>
</tr>
</table>
</td>
</tr>

<tr>
<td>
<hr>
</td>
</tr>

<tr>
<td align="center">
<table id="tagTable" width="90%" border="1" cellspacing="0"
cellpadding="1">

<!-- get Device name -->
<tr>
<td class="input-style-4">
<div align="right">
Name :&nbsp;
</div>
</td>
<td class="input-style-4">
&nbsp;
<input name="<%=Device.NAME%>" type="text"
value="<%=theDevice.getName()%>" size="31"
maxlength="20">
</td>
</tr>

<!-- show or get the device type -->
<tr>
<td class="input-style-4">
<div align="right">
Type :&nbsp;
</div>
</td>
<% if ( 0 == theDevice.getType().length()
|| ( true == theDevice.isQr()
&& false == theDevice.isQrRx() ) )
{ %>
<td class="input-style-4">
<select name="<%=Device.TYPE%>" onChange="enableIgnore();">
<option value="none" selected>Select A Type</option>
<% if ( 0 == theDevice.getType().length() || false == theDevice.isUniversal() ) { %>
<option value="<%=Device.WALL%>" <%=(theDevice.getType().equals( Device.WALL ) ? "selected=\"true\"" : "")%>><%=Device.getTypeTranslated( Device.WALL )%></option>
<option value="<%=Device.PULL%>" <%=(theDevice.getType().equals( Device.PULL ) ? "selected=\"true\"" : "")%>><%=Device.getTypeTranslated( Device.PULL )%></option>
<option value="<%=Device.PULLS%>" <%=(theDevice.getType().equals( Device.PULLS ) ? "selected=\"true\"" : "")%>><%=Device.getTypeTranslated( Device.PULLS )%></option>
<option value="<%=Device.PULLP%>" <%=(theDevice.getType().equals( Device.PULLP ) ? "selected=\"true\"" : "")%>><%=Device.getTypeTranslated( Device.PULLP )%></option>
<option value="<%=Device.PULLC%>" <%=(theDevice.getType().equals( Device.PULLC ) ? "selected=\"true\"" : "")%>><%=Device.getTypeTranslated( Device.PULLC )%></option>
<option value="<%=Device.EMER%>" <%=(theDevice.getType().equals( Device.EMER ) ? "selected=\"true\"" : "")%>><%=Device.getTypeTranslated( Device.EMER )%></option>
<% }
if ( 0 == theDevice.getType().length() || true == theDevice.isUniversal() ) { %>
<option value="<%=Device.NURSECALL%>" <%=(theDevice.getType().equals( Device.NURSECALL ) ? "selected=\"true\"" : "")%>><%=Device.getTypeTranslated( Device.NURSECALL )%></option>
<option value="<%=Device.SMOKE%>" <%=(theDevice.getType().equals( Device.SMOKE ) ? "selected=\"true\"" : "")%>><%=Device.getTypeTranslated( Device.SMOKE )%></option>
<option value="<%=Device.CODETECT%>" <%=(theDevice.getType().equals( Device.CODETECT ) ? "selected=\"true\"" : "")%>><%=Device.getTypeTranslated( Device.CODETECT )%></option>
<option value="<%=Device.DOORWIN%>" <%=(theDevice.getType().equals( Device.DOORWIN ) ? "selected=\"true\"" : "")%>><%=Device.getTypeTranslated( Device.DOORWIN )%></option>
<option value="<%=Device.DOOREAC%>" <%=(theDevice.getType().equals( Device.DOOREAC ) ? "selected=\"true\"" : "")%>><%=Device.getTypeTranslated( Device.DOOREAC )%></option>
<option value="<%=Device.DOORMAN%>" <%=(theDevice.getType().equals( Device.DOORMAN ) ? "selected=\"true\"" : "")%>><%=Device.getTypeTranslated( Device.DOORMAN )%></option>
<option value="<%=Device.DOORCHECKIN%>" <%=(theDevice.getType().equals( Device.DOORCHECKIN ) ? "selected=\"true\"" : "")%>><%=Device.getTypeTranslated( Device.DOORCHECKIN )%></option>
<option value="<%=Device.PIR%>" <%=(theDevice.getType().equals( Device.PIR ) ? "selected=\"true\"" : "")%>><%=Device.getTypeTranslated( Device.PIR )%></option>
<option value="<%=Device.UNIV%>" <%=(theDevice.getType().equals( Device.UNIV ) ? "selected=\"true\"" : "")%>><%=Device.getTypeTranslated( Device.UNIV )%></option>
<% } %>
</select>
</td>
<% } else { %>
<td class="input-style-4"><%=theDevice.getTypeTranslated()%></td>
<input type="hidden" name="<%=Device.TYPE%>" value="<%=theDevice.getType()%>">
<% } %>
</tr>

<!-- get supervision -->
<tr>
<td class="input-style-4">
<div align="right">
Supervised :&nbsp;
</div>
</td>
<td class="input-style-4">
<input name="<%=Device.SUPERVISION%>" type="checkbox"
value="true"
<%=(true == theDevice.getSupervision() ? "checked" : "")%>
onChange="supervisionToggle();">
</td>
</tr>

<!-- get supervision time, if applicable -->
<% if ( 0 == theDevice.getType().length() || (true == theDevice.isQr() && false == theDevice.getType().equals( Device.RXR )) )
{
int superTm = theDevice.getSupervisionTm();
if ( -2 == superTm )
superTm = -1;
%>
<tr>
<td class="input-style-4">
<div align="right">
Supervise Time :&nbsp;
</div>
</td>
<td class="input-style-4">
<select class="input-style-4" name="<%=Device.SUPER_TM%>" id="<%=Device.SUPER_TM%>">
<option value="-1" <%=((superTm == -1) ? "selected" : "")%>><%=LicenseSettings.getInstance().getStringUnit()%> Default</option>
<option value="90" <%=((superTm == 90) ? "selected" : "")%>>90 seconds</option>
<option value="120" <%=((superTm == 120) ? "selected" : "")%>>2 minutes</option>
<option value="180" <%=((superTm == 180) ? "selected" : "")%>>3 minutes</option>
<option value="240" <%=((superTm == 240) ? "selected" : "")%>>4 minutes</option>
<option value="300" <%=((superTm == 300) ? "selected" : "")%>>5 minutes</option>
<option value="360" <%=((superTm == 360) ? "selected" : "")%>>6 minutes</option>
<option value="420" <%=((superTm == 420) ? "selected" : "")%>>7 minutes</option>
<option value="480" <%=((superTm == 480) ? "selected" : "")%>>8 minutes</option>
<option value="540" <%=((superTm == 540) ? "selected" : "")%>>9 minutes</option>
<option value="600" <%=((superTm == 600) ? "selected" : "")%>>10 minutes</option>
<option value="900" <%=((superTm == 900) ? "selected" : "")%>>15 minutes</option>
<option value="1800" <%=((superTm == 1800) ? "selected" : "")%>>30 minutes</option>
<option value="3600" <%=((superTm == 3600) ? "selected" : "")%>>60 minutes</option>
<option value="5400" <%=((superTm == 5400) ? "selected" : "")%>>90 minutes</option>
<option value="7200" <%=((superTm == 7200) ? "selected" : "")%>>2 hours</option>
<option value="14400" <%=((superTm ==14400) ? "selected" : "")%>>4 hours</option>
<option value="21600" <%=((superTm ==21600) ? "selected" : "")%>>6 hours</option>
<option value="43200" <%=((superTm ==43200) ? "selected" : "")%>>12 hours</option>
<option value="86400" <%=((superTm ==86400) ? "selected" : "")%>>24 hours</option>
</select>
</td>
</tr>
<% } %>

<% if ( true == theDevice.is9600() && ( true == theDevice.getType().equals( Device.RXR ) ||
true == theDevice.getType().equals( Device.LOC ) ||
true == theDevice.getType().equals( Device.QLI ) ) )
{ %>
<tr>
<td class="input-style-4">
<div align="right">Channel :&nbsp;</div>
</td>
<td class="input-style-4">
<%
for( int j=11; j<=26; j++ )
{
String channel = String.format("%d", j);
String channelName = "channel" + channel;
if (j != 26 ){
%>
<input type="checkbox" value="<%=j%>" name="<%=channelName%>" <%=true==theDevice.getChannel(j)?"checked":""%>><%=channel%>
<% } else { %>
<input type="checkbox" value="<%=j%>" name="<%=channelName%>" DISABLED><%=channel%>
<%} }%>
</td>
</tr>
<% } %>

<% if ( true == theDevice.is9600() && true == theDevice.isUniversal() )
{ %>
<tr>
<td class="input-style-4">
<div align="right">External Input Mode :&nbsp;</div>
</td>
<td class="input-style-4">
<input type="radio" value="0" name="<%=Device.IMode%>" <%=0==theDevice.getInputMode()?"checked":""%>>ignore
<input type="radio" value="1" name="<%=Device.IMode%>" <%=1==theDevice.getInputMode()?"checked":""%>>trigger event
<input type="radio" value="2" name="<%=Device.IMode%>" <%=2==theDevice.getInputMode()?"checked":""%>>manual reset
</td>
</tr>

<tr>
<td class="input-style-4">
<div align="right">Tamper Tape :&nbsp;</div>
</td>
<td class="input-style-4">
<input type="radio" value="false" name="<%=Device.Tape%>" <%=false==theDevice.isTamperTape()?"checked":""%>>ignore
<input type="radio" value="true" name="<%=Device.Tape%>" <%=true ==theDevice.isTamperTape()?"checked":""%>>use
</td>
</tr>

<tr>
<td class="input-style-4">
<div align="right">Case Open :&nbsp;</div>
</td>
<td class="input-style-4">
<input type="radio" value="false" name="<%=Device.Case%>" <%=false==theDevice.isCaseOpen()?"checked":""%>>ignore
<input type="radio" value="true" name="<%=Device.Case%>" <%=true ==theDevice.isCaseOpen()?"checked":""%>>use
</td>
</tr>

<tr>
<td class="input-style-4">
<div align="right">Contact Type :&nbsp;</div>
</td>
<td class="input-style-4">
<input type="radio" value="false" name="<%=Device.Contact%>" <%=false==theDevice.isInputContactType()?"checked":""%>>normally open
<input type="radio" value="true" name="<%=Device.Contact%>" <%=true ==theDevice.isInputContactType()?"checked":""%>>normally closed
</td>
</tr>
<% }
else
{ %>
<input type="hidden" value="" name="<%=Device.IMode%>">
<input type="hidden" value="" name="<%=Device.Tape%>">
<input type="hidden" value="" name="<%=Device.Contact%>">
<input type="hidden" value="" name="<%=Device.Case%>">
<% } %>

<!-- Auto enroll from this device type -->
<% if ( true == theDevice.getType().equals( Device.ABR ) )
{ %>
<tr>
<td class="input-style-4">
<div align="right">Auto-Enroll :&nbsp;</div>
</td>
<td class="input-style-4">
<input type="checkbox" value="true" name="<%=Device.Auto%>"<%=(true == theDevice.getAutoEnroll() ? "checked" : "")%>>
</td>
</tr>
<% } %>
</table>
</td>
</tr>

<% if ( 0 == theDevice.getType().length() || (true == theDevice.isQr() && false == theDevice.isQrRx()) )
{ %>
<tr>
<td>
<hr>
</td>
</tr>

<tr>
<td align="center">
<table width="90%" border="0" cellspacing="0"
cellpadding="1">
<tr>
<td width="76%" class="input-style-3">
<div align="left">
Ignore Alert
<input name="<%=XMLDeviceBean.IID_ON%>" type="checkbox" onClick="enableIgnore();" <%=iid_on ? "checked" : ""%>>
</div>
</td>
<td width="24%" class="input-style-3">
<div align="left">
</div>
</td>
</tr>
</table>
</td>
</tr>

<tr>
<td align="center">
<table width="90%" border="1" cellspacing="0"
cellpadding="1">
<tr>
<td width="24%" class="input-style-4">
&nbsp;
</td>
<td width="76%" class="input-style-4">
&nbsp;
</td>
</tr>
<tr>
<td class="input-style-4">
<div align="right">
Begin :
</div>
</td>
<td class="input-style-4">
<select name="<%=XMLDeviceBean.IID_BEG%>">
<% for ( int x = 0; x < times.length; x++ )
{ %>
<option value="<%=times[x]%>" <%=(ignoreBeginTime.equals( times[x] ) ? "selected=\"true\"" : "")%>><%=times[x]%></option>
<% } %>
</select>
</td>
</tr>
<tr>
<td class="input-style-4">
<div align="right">
End :
</div>
</td>
<td class="input-style-4">
<select name="<%=XMLDeviceBean.IID_END%>">
<% for ( int x = 0; x < times.length; x++ )
{ %>
<option value="<%=times[x]%>" <%=(ignoreEndTime.equals( times[x] ) ? "selected=\"true\"" : "")%>><%=times[x]%></option>
<% } %>
</select>
</td>
</tr>
</table>
</td>
</tr>

<!-- ends row for device entry -->

<tr>
<td>
<hr>
</td>
</tr>

<% } %>

<!-- Row for buttons -->
<tr>
<td align="center">
<table width="50%" border="0" cellspacing="2"
cellpadding="5">
<tr>
<td >
<div align="center">
<input name="btnSave" type="button" id="btnSave" value="Save" onClick="handleProperties();">
</div>
<td class="input-style-4">
<div align="center">
<input name="btnCancel2" type="button" id="btnCancel2" onClick="handleClose();" value="Close">
</div>
</td>
<td class="input-style-4">
<div align="center">
<input name="btnSaveNext" type="button" id="btnSaveNext" onClick="handleSaveNext();" value="Save & Next">
</div>
</td>
<td class="input-style-4">
<div align="center">
<input name="btnNext" type="button" id="btnNext" onClick="handleNext();" value="Next">
</div>
</td>
</tr>
</table>
</td>
</tr>
<!-- ends row for buttons -->
</table>
</td>
<!-- This ends "the main content column" -->
<% } // if ( null != theDevice.getGUID() )
else
{ %>
<td class="main-column">
<!-- the NULL DEVICE content column -->
<table width="100%" border="0" cellspacing="0" cellpadding="0"
bgcolor="#EFEFEF">
<tr>
<td align="center">
<table width="90%" border="1" cellspacing="0"
cellpadding="1">
<tr>
<td class="input-style-3">
<div align="center">
COULD NOT UPDATE DEVICE
</div>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center">
<table width="90%" border="1" cellspacing="0"
cellpadding="1">
<tr>
<td width="50%">
<div align="center">
<input name="btnCancel" type="button" id="btnCancel"
onClick="handleClose();" value="Close">
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<!-- This ends "the NULL DEVICE content column" -->
<% } %>
</tr>
<!-- this ends "a row with the body of the page" -->
</table>
<!-- This ends the "Table 1: And one table to hold them all" -->
</td>
</tr>
</table>
</form>
</body>
Santanu
 
Posts: 16
Joined: Sat Aug 09, 2008 5:20 pm

Postby rangana on Wed Aug 13, 2008 11:58 pm

I'm so sorry, this goes out of my wits. Seing ASP, baffles me, and also, edit your post. Place it inside the [code][/code ] tag.
User avatar
rangana
500+ Club
 
Posts: 935
Joined: Wed Feb 27, 2008 5:14 am
Location: Cebu City Philippines


Who is online

Users browsing this forum: No registered users and 3 guests