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!

Same page asp processing doesn't work in Netscape, fine in IE

Status
Not open for further replies.

msuryadarma

Programmer
Oct 13, 2000
3
US
Hi all, I have an asp page that accepts users input in textboxes, process them, and writes the output on the same page. This page is written in javascript, it works fine in IE, but doesn't work in Netscape.

Here's how it works:
1.html: User enters a number x. Press Submit.
2.asp: Opens up with x number of textboxes, ready for input. A submit button. There is a second set of x textboxes to place the output after user presses Submit. Let's just say if the input is 3, after pressing submit the output in the 2nd set of textbox is 6.

So all the input, calculations, and output is done on one page, 2.asp. Is this even possible in netscape?

This is the code of 2.asp. Let me say that transition from 1.html to 2.asp works fine. It messes up when I press Calculate on 2.asp.

The server-side script is written in VBScript, yes. The client-side used to be in VBScript as well, but I wanted to make it work for Netscape, that's why I'm converting it to JavaScript.

<%@ LANGUAGE=&quot;VBScript&quot; %>
<html>

<head>
<title></title>
<script LANGUAGE=&quot;JavaScript&quot;>

//Function to calculate (input * 2)
function Calculate() {

var BN = document.frmBoxes.txtBN.value

for (var Ctr = 0; Ctr <= (GN - 1); Ctr++) {
var Input = document.frmBoxes.txtInput(Ctr).value
var Result = (Input * 2)
document.frmBoxes.txtResult(Ctr).value = Result
}
}

</script>
</head>

<body>

<form NAME=&quot;frmBoxes&quot;>
<table>
<%
Dim BoxNum

//Getting the input from 1.html for # of boxes to display
BoxNum = Request.Form(&quot;txtBoxNum&quot;)

//Writing how many boxes is requested.
Response.Write &quot;<tr><td align=right><b># of Boxes:</b></td><td><input TYPE=text NAME=txtBN SIZE=5 VALUE=&quot; & GuestNum & &quot; READONLY TABINDEX=0></td></tr>&quot;

//Drawing the textboxes.
For Counter = 1 to BoxNum
Response.Write &quot;<tr><td><b><u>Box &quot; & Counter & &quot;Input:</u></b></td><td><input TYPE=text NAME=txtInput SIZE=10></td>&quot; & _
&quot;<td> =============> </td><td><b>Box &quot; & Counter & &quot; Result: $<td></b><input TYPE=text NAME=txtResult SIZE=10 READONLY TABINDEX=0></td></tr>&quot;
Next

%>
</table>
</form>

<form NAME=&quot;frmCalc&quot; OnSubmit=&quot;Calculate(); return false;&quot;>
<p><input TYPE=&quot;submit&quot; NAME=&quot;cmdCalc&quot; VALUE=&quot;Calculate!&quot; SIZE=&quot;15&quot; TABINDEX=&quot;32766&quot;> </p>
</form>
</body>
</html>

I didn't put action= in the frmCalc frame because this is not going to any other page. But even then, I tried putting action=&quot;2.asp&quot; and it still doesn't work.

So what happens if I press Calculate? The page refreshes and deletes all the textboxes, and just displays txtBN textbox and the Submit button.

Thank you very much for any help.

Martin

[sig][/sig]
 
I can see a few things in your code without even trying to run it:

your calculate function uses a variable GN that never gets assigned a value.

change the form declaration to accept a return value from the onsubmit handler, and change the Calculate function to return false:

<form NAME=&quot;frmCalc&quot; OnSubmit=&quot;return Calculate()&quot;>

also, FYI, Netscape does not support the readonly attribute for text boxes.

After fixing these things, if your page doesn't work, post again, and we'll take a second look.


[sig]<p>nick bulka<br><a href=mailto: > </a><br>[/sig]
 
Nick, thanks a lot for the reply.

1. That GN is a typo, it's supposed to be BN.

Another typo:

//Writing how many boxes is requested.
Response.Write &quot;<tr><td align=right><b># of Boxes:</b></td><td><input TYPE=text NAME=txtBN SIZE=5 VALUE=&quot; & BoxNum & &quot; READONLY TABINDEX=0></td></tr>&quot;

It should be BoxNum, instead of GuestNum as in above code. Sorry about that.

2. Tried changing to <form NAME=&quot;frmCalc&quot; OnSubmit=&quot;return Calculate()&quot;> and it still doesn't work.

Okay, here's the URL of my project. Check it out there. Try it with IE, then try it with Netscape.

BTW, Netscape doesn't support READONLY for textboxes either huh?

Thanks a lot!

Martin
[sig][/sig]
 
Martin,
Whenever you have a problem with Netscape, go to the URL address box and type in

javascript:

(don't forget the colon). You'll get the javascript console. If you do this with your page, you'll see that Netscape thinks txtguesteat is a function, because you're putting (ctr) behind it.

By the way, Netscape will keep all errors in the console until you explicitly clear it.

[sig]<p>nick bulka<br><a href=mailto: > </a><br>[/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top