• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Changing document.Check.lastBarcode.value to object in JSP javascript

 
Moined Mogul
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the if statement below that I want to use. When I use it I am told that lastBarcode is not an object.
If I replace the document.Check.lastBarcode.value with "2000", it works the way it is suppose to by the user getting the alert if they enter a value for barcode that is less than 2000.
How is it that I can use lastBarcode like I do below but as an object???
Please help!!!

if(document.Check.Barcode.value > document.Check.lastBarcode.value)
{
alert("Sorry, you must enter a barcode that is greater than " + document.Check.lastBarcode.value);
return false;
}
 
Sam Dalton
Author
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Would really need to see the form that contains barcode and lastbarcode to tell you why this doesnt work.
This is not really a servlet/JSP problem however!
S
 
Moined Mogul
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
PLEASE HELP!!!
This is the code in my JSP that I am trying to get to work:
<script language="JavaScript1.2">
var a = parseInt(document.Check.Barcode.value);
var b = parseInt(document.Check.largestBarcode.value);
if(a > b)
{
alert("Sorry, you must enter a barcode that is greater than the one you just entered");
return false;
}
}
</script>
<tr>
<input type="hidden" name="largestBarcode" value="<%=(adminFunctions.lastBarcode(libraryBook))%>">
This is my bean method that gets the largest number form my database:
public synchronized int lastBarcode (Resource resource)
{
Vector vResourceList = new Vector();
String[] alResourceList = null;
int nArraySize = 0;
double fValue = 0;
Double tempDouble;
int nBarcode = 0;
try
{
m_Statement = m_Connection.createStatement();
m_Results= m_Statement.executeQuery (m_strBarcode);
while (m_Results.next())
{
vResourceList.addElement(new String(m_Results.getString("scancode")));
}
m_Statement.close();
}
catch (SQLException queryFails)
{
System.out.println("Exception retrieving resource list " + queryFails.getMessage());
}
alResourceList = new String[vResourceList.size()];
//Moving into array to use in JSP page
vResourceList.toArray(alResourceList);
//Getting the size of the array
nArraySize = (alResourceList.length);
tempDouble = Double.valueOf(alResourceList[nArraySize-1]) ;
fValue = tempDouble.doubleValue() ;
nBarcode = (int)fValue;
return (nBarcode);
}

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic