Networking | Hardware | Software | Multimedia | System | Unix&Linux | MBA

Home>>Hardware>>Problem in Script

Problem in Script

saurav
03-16-2006, 08:19 AM
Hi Guyz am having a problem in script.
Here goes the script


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script language=javascript>
function BookingDetailsFin()
{
alert("saurav");
var tn = "1010243/cr";
int f=0;
var temp = null;
var temp1 = null;
var tasknumber = tn.value;
var tasknolength = tasknumber.length;
alert("Length is "+tasknumber.length);
temp = tasknumber.substring(0,7);
temp1= tasknumber.substring(7,10);
//var last = name.substring(len-3,len);
if(tasknumber == "")
{
alert("Please enter the Task Number");
//tn.page_taskno.focus();
//return false;
}
for(int i=0; i<temp.length; i++)
{
if(temp[i] >= '0' && temp[i] <= '9')
{
f++;
}
}
for(int i=0; i<temp.length; i++)
{
if((chr[i] >= 'A' && chr[i] <= 'Z') || (chr[i] >= 'a' && chr[i] <= 'z'))
{
f++;
}
}
if(!(f>0))
{
alert("please enter the alpha numeric vals");
}

else
{
var last2 = "/DR";
var last3 = "/CR";
if (temp1 == last2 || temp1 == last3)
{
alert("the string is equal");
}
else
{
alert("Enter proper value");
//tn.page_taskno.focus();
//return false;
}
}
}


/*function BookingDetailsFin()
{
alert("saurav");
}*/
</script>


</HEAD>

<BODY>
<input type ="button" name="aa" value="aa" onClick="javascript:BookingDetailsFin()" >
</BODY>
</HTML>




Clicking on the button isnt taking me to the desired func.......the func which i have written above.
but when i tried with one simple func which i had commented it was showing me the alert message.Guyz please help me out here.

Thanks in advance.

Saurav

Kor
03-16-2006, 11:23 AM
var tn = "1010243/cr";
var temp = null;
var temp1 = null;
var tasknumber = tn.value;??
tn is variable. It value is a string. A string does not support value attribute (it will return undefined)

What tn suppose to be? An element with name ='1010243/cr'? If so, there are 2 mistakes. name and id should start only with a letter or underscore, not with a number. And the elements must be an object, not a string

var tn = document['formname']['elementname']

But looking at your commented:
//tn.page_taskno.focus()

tn looks rather like the form, but a form has no value... Is this a kind of validation code, or what?

saurav
03-16-2006, 03:41 PM
Thanks Kor for your reply.
Actually this script is a part of a big jsp,where you are right that is an object.
I was actually trying to do the draft in just a simple html page.

Kor
03-16-2006, 04:53 PM
ok, so? Is there any other problem?


 

TOP

Hyperthreading hurts s
HP sharpens blade PC l
Apple goes for Quad po
Itanium gets scaled do

For more info

HP sharpens blade PC l
Hyperthreading hurts s
can not call click() i
script does not work o
smart menu 
write to an html file 
FireFox doesn't recogn
Changing e.keyCode (e.
Clearing a range creat
UPDATE: My mouse over 

News Archive

onChange Help 
beforeload? vs onload.
Problem with document.
decreasing my javascri
Problem with \\ and \ 
how to stop scrolling?
Change Label Text Colo
Can I forward a page b
2 javascript functions
Validating a textbox 

Related stories:

Mozilla + Mediplayer + Javascript
Looking for a script that scrolls
Stock Data
Restrict Scrolling
Make the only clickable area the center of the screen
Am I missing something, Validating?
validate string
Having trouble with some javascript code...
Script for date validation...

Copyright@2004-2005 www.zzcoke.com All Right Reserved

advanced web statistics