Click to See Complete Forum and Search --> : Data control


BarryMVS
06-13-2003, 10:14 AM
I'm looking for a bit of help.

I have an ASP web page that controls it's sessions by using the Auth_User server variable.

The problem I have is the variable is returned as 'servername/username'. I need this variable to be avalible in a friendly version as just the username.

I can pull the server variable into JavaScript by using the '<!--#echo var="Auth_User"-->' statement.

What I need to know is if there is anyway I can then delete the first 7 charicters, being the servername, leaving just the username, which I can the return to another variable to be used later on in the page?

I think that's the best way I can find to explain it.

Any help would be most welcomed.

Thanks,

Barry.

Jona
06-13-2003, 10:21 AM
Originally posted by BarryMVS
What I need to know is if there is anyway I can then delete the first 7 charicters,


<script type="text/javascript">
<!--
onload = function(){
var username = '<!--#echo var="Auth_User"-->'
document.getElementById("hidDiv").innerHTML=username;
username = username.substring(7,username.length);
document.getElementById("hidDiv").innerHTML=username;
document.getElementById("hidDiv").style.position="relative";
document.getElementById("hidDiv").style.display="block";
}
//-->
</script></head><body>
<div style="display:none;position:absolute;" id="hidDiv"></div>
</body></html>


Jona

Khalid Ali
06-13-2003, 10:22 AM
There are multiple ways in JS you can use.
As you mentioned the data returned to you is in this format
'servername/username'
put this in a variable,e.g

var temp = 'servername/username'
var userName=(temp.split("/"))[1]
alert(userName)