aspose file tools*
The moose likes Servlets and the fly likes Changing document.Check.lastBarcode.value to object in JSP javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Changing document.Check.lastBarcode.value to object in JSP javascript" Watch "Changing document.Check.lastBarcode.value to object in JSP javascript" New topic
Author

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

Moined Mogul
Ranch Hand

Joined: Jul 11, 2001
Posts: 33
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

Joined: Jul 26, 2001
Posts: 170
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


<a href="http://www.samjdalton.com" target="_blank" rel="nofollow">Sam Dalton</a>,<br />Co-author of [http://www.amazon.com/exec/obidos/tg/detail/-/1590592255/qid=1068633302//ref=sr_8_xs_ap_i0_xgl14/104-4904002-9274339?v=glance&s=books&n=507846]Professional JSP 2.0[/URL] (October 2003)<br />Co-author of <a href="http://www.amazon.com/exec/obidos/ASIN/1861007701/ref=ase_electricporkchop" target="_blank" rel="nofollow">Professional SCWCD Certification</a><br />Co-author of <a href="http://www.amazon.com/exec/obidos/ASIN/186100561X/ref=ase_electricporkchop" target="_blank" rel="nofollow">Professional Java Servlets 2.3</a>
Moined Mogul
Ranch Hand

Joined: Jul 11, 2001
Posts: 33
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);
}

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Changing document.Check.lastBarcode.value to object in JSP javascript