Click to See Complete Forum and Search --> : User Input Redirect (html) to New Page


steverf
10-30-2006, 11:45 AM
Hello All,
I am looking for a reliable cross browser method to have a user input a string (order number) and be redirected to a new page based on their input. I need to gracefully fail if the page does not exist. I have tried various methods that did not work reliably and just found this forum... Sure would appreciate any assistance. Many Thanks..SteveRF

TheBearMay
10-30-2006, 12:22 PM
Assuming javascript is enabled and the files are in the same domain:


function getFile(fileName){
oxmlhttp = null;
try{
oxmlhttp = new XMLHttpRequest();
oxmlhttp.overrideMimeType("text/xml");
}
catch(e){
try{
oxmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e){
return null;
}
}
if(!oxmlhttp) return null;
try{
oxmlhttp.open("GET",fileName,false);
oxmlhttp.send(null);
}
catch(e){
return null;
}
return oxmlhttp.responseText;
}
function xferCheck(fileNm) {
fileNm+=".htm";
if (getFile(fileNm+".htm") != null)
document.location.href=fileNm;
else
alert ("Requested file "+fileNm+" is not available");
}
...
<input type="text" id="fNum" />
<button onclick="xferCheck(document.getElementById('fNum').value)";

steverf
10-30-2006, 08:04 PM
To: TheBearMay...
Many Thanks, I am going to try this tomorrow and se how it goes... maybe I can actually follow your idea and make it work. I appreciate your time and assistance.
SteveRF (another Old Guy)

steverf
10-30-2006, 08:28 PM
Hello,
Well, I tried... probably left out a <script> or something... I did get the prompt and am in the main domain (selection option will be on the index page)...I'll keep trying...
currently input and button push gives no response..
Thank u for taking the time to help..I appreciate !
SteveRF