Haskin Posted August 11, 2006 Share Posted August 11, 2006 hi ...I need serious help...I have been told that the javascript that I have is not going to do what I wanted it ...I am needing to create a text box on the html page ...when a user enters a number it must check on the server to see if the file exists and if so redirect them to that page...so for instance if a user types in 10007 they will be taken to www.helpme.org/10007.htmall the pages with numbers are kept on the server ...eg..10007.htm10008.htm10009.htmso if a user types in a numnber of a file that does not exist it will give an alert box saying that it does not exist. Th JS that I have is as followsvar arr=['100000', '100002']//possible valuesfunction goto(v) {for(var i=0;i<arr.length;i++){if(v==arr){//if(v==){location.href='http://www.africanmob.com/'+v+'.htm';return;}}alert('This page does not exist!')}// JavaScript DocumentThe code in my html file is<form><input name="Input" type="text" id="url" size="5"><span style="cursorointer" onclick="goto(document.getElementById('url').value)" class="style31">Go to Dealer </span></form>I can't use the array because there are going to be to many files for me to keep updating so I need something that is going to check the server that the file exists and if so then direct the user there...I really hope someone can help me ..I need to get this up and running by next week... Link to comment Share on other sites More sharing options...
Reg Edit Posted August 11, 2006 Share Posted August 11, 2006 As an alternative to a rewrite in ASP, you may want to consider implementing a custom 404 error page on the server.There's a lot of info on the web about doing this but for starters try http://webdesign.about.com/od/http/a/aa031306.htm Link to comment Share on other sites More sharing options...
justsomeguy Posted August 11, 2006 Share Posted August 11, 2006 var arr=['100000', '100002']//possible valuesThat's not how you define an array, you use parentheses instead of square brackets, and use the Array constructor:var arr = new Array('100000', '100002');//possible valuesOr you can also use push.var arr = new Array();arr.push('100000');arr.push('100002'); Link to comment Share on other sites More sharing options...
Haskin Posted August 14, 2006 Author Share Posted August 14, 2006 var arr=['100000', '100002']//possible valuesThat's not how you define an array, you use parentheses instead of square brackets, and use the Array constructor:var arr = new Array('100000', '100002');//possible valuesOr you can also use push.var arr = new Array();arr.push('100000');arr.push('100002');Whats wrong with this asp code it comes up with an error Microsoft VBScript runtime error '800a01a8'Object required: '[string: "c:\Melissa\Melissa's"]'/thisfile.asp, line 15 {thisfile.asp}<?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>Untitled Document</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /></head><body><%dim fValfVal=Request.QueryString("fVal")If (fVal) thenSet fileName="c:\Melissa\Melissa's work\African Mob\Website\" & fVal & ".htm"Set fs=Server.CreateObject("Scripting.FileSystemObject")If (fs.FileExists(fileName))=true ThenResponse.Redirect("www.africanmob.com/"&fVal&".htm")ElseResponse.Write("www.africanmob.com"&fVal&".htm does not exist.")End IfEnd Ifset fs=nothing%> </body></html>the htm page contains <form action="thisfile.asp" method="get"><input type="text" name="fVal" /><input type="submit" value="Submit" /></form> Anyone got anyideas? Link to comment Share on other sites More sharing options...
justsomeguy Posted August 14, 2006 Share Posted August 14, 2006 Don't use the set keyword. I've never quite understood when set is used, but I believe that is the problem. Link to comment Share on other sites More sharing options...
Haskin Posted August 14, 2006 Author Share Posted August 14, 2006 Don't use the set keyword. I've never quite understood when set is used, but I believe that is the problem.Ok but what would I use instead? Link to comment Share on other sites More sharing options...
justsomeguy Posted August 14, 2006 Share Posted August 14, 2006 nothing. remove set Link to comment Share on other sites More sharing options...
Haskin Posted August 15, 2006 Author Share Posted August 15, 2006 nothing. remove setYes thanks its sorted jeez so desperate ! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now