ASP+VBScript

Asked By JAYA PRAKASH
09-Feb-10 12:18 AM
Earn up to 0 extra points for answering this tough question.
In this program iam trying to read and store the elements in an array. But it is not storing the elements in an array.
Can anyone please help to correct the errors
<%@LANGUAGE="VBSCRIPT" %>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<%dim n,i%>
<%dim a(10)%>
<%Response.write(date)%>
<%Response.Write("<" & "script language=VBScript>")
Response.Write("InputBox ""Enter the no of elements" & n & """<" & "/script>")%>
<%for  i = 1 to n
Response.Write("<" & "script language=VBScript>")
Response.Write("InputBox ""Enter the array elements" & a(i) & """<" & "/script>")
Response.write("Array" & a(i))
Response.write(n)
next%>
<%for  i = 1 to n
Response.Write("<" & "script language=VBScript>")
Response.Write("MsgBox """ & a(i) & """<" & "/script>")
next%>
</head>
<body>
<form action="array.asp" method="post" name="f">
<input type="submit" name="Display" value="Display">
</form>
</body>
</html>

  I already responded to this in your previous attempt

  re: I already responded to this in your previous attempt

JAYA PRAKASH replied to Robbe Morris
09-Feb-10 10:24 AM
I tried in the way you said. Please can you modify the program so that it can read array elements(not assigning the values to array elements).
Iam in urgent need of the program.

  I didn't suggest a coding technique.

Robbe Morris replied to JAYA PRAKASH
09-Feb-10 10:59 AM
So, I'm not sure what "tried the way you said" means.

You've intertwined client side code with server side code expecting the two to be able to share variable values.  Doesn't work that way.  You cannot directly populate server side variable with an InputBox or anything else captured client side.

The server and browser are "completely" disconnected.  To get a value from JavaScript into your ASP server side code, you must post that value back to the server.  In classic ASP, the easiest way for a beginner like yourself would be to populate a hidden form element in the page with your client side script.  Then, submit the page back to itself and have your server side asp code grab the value of the hidden form element.
Create New Account