Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB script to javascript conversion

Status
Not open for further replies.

Ouch

Programmer
Jul 17, 2001
159
GB
Can anyone assist me converting this simple vbscript to javascipt?

i know nothing about javascript

<%
'===========================================
'== Here are the variables you can customise
'===========================================
AppTitle = &quot;Testing&quot;
AppUsername = &quot;MyAppUser&quot;
AppPassword = &quot;MyPasword&quot;
AppCookie = &quot;MyCookie&quot;
Group=&quot;&quot;
UserType=&quot;&quot;

'=================================
' don't change anything below here
'=================================

strAuth = request.Cookies(Appcookie)

if strAuth = &quot;false&quot; OR strAuth = &quot;&quot; then

CReturnURL= Request.ServerVariables(&quot;SERVER_NAME&quot;)&_
Request.ServerVariables(&quot;PATH_INFO&quot;)

response.Cookies(&quot;RetURL&quot;) = CReturnUrl
response.Cookies(&quot;AppTitle&quot;) = AppTitle
response.Cookies(&quot;AppUsername&quot;) = AppUsername
response.Cookies(&quot;AppPassword&quot;) = AppPassword
response.Cookies(&quot;CookieName&quot;) = AppCookie
response.Cookies(&quot;group&quot;) = Group
response.Cookies(&quot;UserType &quot;) = UserType

response.redirect(&quot;
end if

Department = request.Cookies(&quot;Department&quot;)
Email = request.Cookies(&quot;Email&quot;)
Username = request.Cookies(&quot;Username&quot;)
FullName = request.Cookies(&quot;FullName&quot;)
Surname = request.Cookies(&quot;SN&quot;)
FirstName = request.Cookies(&quot;FS&quot;)
ADsPath = request.Cookies(&quot;ADsPath&quot;)
 
The cookies that you are using in this code are server-side. Client-side cookies exsist in a text string - maybe this code will help you...

function JSsetCookies(){
var formStr = &quot;&quot;;
expireDate = new Date
expireDate.setDate(expireDate.getDate()+30)
for (x=0; x<document.daForm.elements.length; x++){
formStr += document.daForm.elements[x].name + &quot;@@&quot; + document.daForm.elements[x].value + &quot;##&quot;
}
document.cookie = &quot;<%=cbr%>=&quot;+formStr+&quot;;expires=&quot; + expireDate.toGMTString()
}
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
function JSreadCookies(){
thisCookie = document.cookie.split(&quot;; &quot;)
for (x=0; x< thisCookie.length; x++){
if (thisCookie[x].split(&quot;=&quot;)[0] == &quot;<%=cbr%>&quot;){
frmCookie = thisCookie[x].split(&quot;=&quot;)[1].split(&quot;##&quot;)
}
}
if (typeof frmCookie==&quot;object&quot;){
for (x=0; x<frmCookie.length; x++){
fieldName = frmCookie[x].split(&quot;@@&quot;)[0]
if (fieldName != &quot;&quot;){
frmField = document.getElementById(fieldName)
frmField.value = frmCookie[x].split(&quot;@@&quot;)[1]
if (fieldName.substr(0,1) == &quot;e&quot;){
if (frmField.value == &quot;No&quot;){
frmField.style.background = &quot;white&quot;
}
}
}
}
}
}
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
function JSkillCookies(){
thisCookie = document.cookie.split(&quot;; &quot;)
expireDate = new Date
expireDate.setDate(expireDate.getDate()-1)
for (x=0; x< thisCookie.length; x++){
cookieName = thisCookie[x].split(&quot;=&quot;)[0]
if (cookieName == &quot;<%=cbr%>&quot;){
document.cookie = cookieName + &quot;=;expires=&quot; + expireDate.toGMTString()
}
}
}

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rich Cook
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top