Link to home
Create AccountLog in
Avatar of savsoft
savsoftFlag for India

asked on

The Substring() Not Giving any value

<script language="javascript">
function gettablename(getdb)
{
var db=getdb;
db=db.substring(1,db.indexOf("/",1));
alert(db);
}
</script>
ASKER CERTIFIED SOLUTION
Avatar of Gurvinder Pal Singh
Gurvinder Pal Singh
Flag of India image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of savsoft

ASKER

Its still not working.. Value is recieveing Well in function but substring function not working..

string is "/TestCMS/"
is there any error message coming in alert?
Avatar of savsoft

ASKER

No...... It seems like stop execution on substring function.. tell me solution
var db="/TestCMS/";
db=db.substring(1,db.indexOf("/",1));
alert(db);

this solution gives me the correct table name.

What exactly is the db value name? Check if that value has some character that needs to be escaped
Avatar of savsoft

ASKER

but if i pass value through function parameter then it is not giving any output.....
Avatar of savsoft

ASKER

name is Excatly "TestCMS" which i send to function through escape string .. It stops working after any string function is called
how will you get indexOf("/") whe when you dont have / in your string :)
savsoft:

Your function does not have a return statement.  The variable 'db' is a local variable that exists only within your function.  Try this:

<script language="javascript">
function gettablename(getdb)
{
var db=getdb;
db=db.substring(1,db.indexOf("/",1));
alert(db);

return db;
}
</script>

Regards,

AielloJ