PDA

View Full Version : Some javascript isn't working in a webobject...


blake
08-24-2004, 02:29 PM
I'm building a hybrid registration and software configuration tool with APMS 5.0 and part of the application needs to run off a webserver -- therefore, I'm using the WEB OBJECT to allow this to happen from within the APMS project/application.

Ok. this javascript web page code works fine when loaded HEAD of the HTML page loaded in the web object on APMS 5.0:

function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'titlebar=1,toolbar=0,scrollbars=0,location=0,stat usbar=0,menubar=0,resizable=0,width=400,height=300 ');");
}


*However*, the following auto-tab code will not work in APMS web object -- yet it works fine in IE and Netscape...


var phone_field_length=0;
function TabNext(obj,event,len,next_field) {
if (event == "down") {
phone_field_length=obj.value.length;
}
else if (event == "up") {
if (obj.value.length != phone_field_length) {
phone_field_length=obj.value.length;
if (phone_field_length == len) {
next_field.focus();
}
}
}
}


Incidentally, this is called in the page like...

<input type=text name="Phone_1" size=3 maxlength=3 nKeyDown="TabNext(this,'down',3)" onKeyUp="TabNext(this,'up',3,this.form.Phone_2)">
-
<input type=text name="Phone_2" size=3 maxlength=3 onKeyDown="TabNext(this,'down',3)" onKeyUp="TabNext(this,'up',3,this.form.Phone_3)">
-
<input type=text name="Phone_3" size=4 maxlength=4>

Occasionally, I even get a system message:
"AutoPlay Application has encountered a problem and needs to close. We are sorry for the inconvenience" with all the attendant windows information...

Any ideas?

~Blake

JimS
08-27-2004, 02:27 AM
Welcome to the Forum blake,
I don’t want you to think you are being ignored, but I don’t have a good answer for you either. Give it another day or two and if you still haven’t received any answers, give it a ‘bump’.

If it’s any conciliation, I spent many hours trying to overcome this same problem, I was using AMS4 at the time. I must say, at least ‘in theory’ your attempt is better than any I tried. I like that javascript.

Unfortunately, at least according to the Help file, the Page.SetFocus doesn’t work for Web Objects. To me, the trouble seems to be that the Web Object loses focus.

OK, here is an idea that may or may not work for you. I understand that part of your application needs to run off a webserver, but I wonder if you can take this one-step further in AMS. It appears to me that you are using this javascript on a form. Usually, the form gets ‘submitted’ to the actual script (PHP, MySQL, PERL, CGI, etc.) that needs to be on the webserver. Depending on how your particular script (webserver program) you are using, and how much control you have to tinker with it, you might be able to use AMS to build your form, and then the HTTP.Submit action, to submit the data to the actual script on the webserver, just like the form you are now using does.

If you build your form in AMS, it’s easy to set tab order.

Sorry I don’t have a more definitive answer for you. Perhaps someone else will.