How to change (document.Check.validate.value) to integer from string
How is it that you can change within javascript in a JSP a value you get using something like this:
document.Check.validate.value
From a string to an integer. I have tried using the Integer.parseInt(document...)
This gives me a runtime error stating that Integer is not defined in the javascript I am trying to run.
PLEASE HELP....
Thank you!
if(Integer.parseInt(document.Check.Barcode.value) == 2000)This is the line exactly that gives me the error.....says that Integer is not defined....
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;
}
Hi,change your if statement like this if(parseInt(document.Check.Barcode.value) == 2000)-priya
I am still getting the runtime error with this:
if((parseInt(document.Check.Barcode.value)) > (parseInt(document.Check.lastBarcode.value)))
{
alert("Sorry, you must enter a barcode that is greater than " + document.Check.lastBarcode.value);
return false;
}
PLEASE HELP!!!!!!!!!!!!!!!!!
Try thisvar a = parseInt(document.Check.Barcode.value);var b = parseInt(document.Check.lastBarcode.value);if (a > b){}
I get the following error when I try to use the below code:
A Runtime Error has occured.
Error: 'document.Check.lastBarcode.value' is not an object
> Try this
>
> var a = parseInt(document.Check.Barcode.value);
> var b = parseInt(document.Check.lastBarcode.value);
>
> if (a > b)
> {
> }
>
>
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);
}
Hi,
if you are getting follow. error
Error: 'document.Check.lastBarcode.value' is not an object
then you have to check name of the form it should be 'Check' then name of your field it should be as it is
'lastBarcode'
It is case sensetive.
Check these things.
I did notice that...and have corrected the name to largestBarcode from lastBarcode which was wrong.
I no longer get the error message but now seem to always get the alert message no matter what number I input. Even if I input 1000000, I am still getting that I need to enter a number larger than the one I entered. The largest number in the database now is 76.
??
what is your barcode value?is it text field ?
This is the tag:<TR><TD ALIGN="right"><B><div class="text">Barcode:</div></B></TD><TD> </TD><TD><INPUT TYPE="TEXT" NAME="Barcode" SIZE="30"></TD></TR>
i think follow pgm will help you.
<html>
<head>
<script>
function f1()
{
var a = parseInt(document.frm.x.value);
var b = parseInt(document.frm.t1.value);
if( a > b)
{
alert ("yes");
}
else
{
alert("no");
}
}
</script>
</head>
<body>
<form name = frm>
<input type = hidden name = x value = 100>
<input type = text name = t1 >
<input type = button value = click onclick = f1()>
</form>
</body>
</html>
Does it have something to do with it being a text field?
have you tried my sample program ?
Thank you so much for your help!!! I relly appreciate it.Your program made me realize that I did not need quotes around:value=<%=(adminFunctions.lastBarcode(libraryBook))%Thank you so much!!!!