Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > asp with javascript

Reply
Thread Tools

asp with javascript

 
 
josema
Guest
Posts: n/a
 
      01-09-2004
Hi to all

I have a asp page that have an array for instance:
<%
a(0)=0
a(1)=1
a(2)=2
a(3)=3
%>
I would like to show each element of the array with
alerts in javascript... Do you know what its the way to
make something like this...

Thanks in advance and happy new year.
josema

 
Reply With Quote
 
 
 
 
Dan Boylett
Guest
Posts: n/a
 
      01-09-2004

"josema" <(E-Mail Removed)> wrote in message
news:0a0701c3d6a6$fdf5de90$(E-Mail Removed)...
> Hi to all
>
> I have a asp page that have an array for instance:
> <%
> a(0)=0
> a(1)=1
> a(2)=2
> a(3)=3
> %>
> I would like to show each element of the array with
> alerts in javascript... Do you know what its the way to
> make something like this...


You need to write your server code into a locally held array - excuse my JS
if it's wrong in terms of syntax, but I tend to program in VB and I'm not
looking up the JS syntax )

So :
<%
a(0)=0
a(1)=1
a(2)=2
a(3)=3
%>
<html>
<body>
<script language ="javascript">
var aLocal(3)

<%
iCounter = 0
for (iCounter=0;iCounter<a.length;iCounter++) {
Response.Write('aLocal(' + iCounter + ') = ' + a(iCounter) + vbnewline
// Whatever the Jscript equivlant is - \n ?
}
%>
for(a=0;a<aLocal.length;a++) {
alert(aLocal(a))
}
</script>
</body>
</html>












 
Reply With Quote
 
 
 
 
Harag
Guest
Posts: n/a
 
      01-09-2004


Alert is a CLIENT site command.

so you would either have the asp code write client code... or just
simply use Response.Write to write out the value.

asp:

for (var i=0; i<a.length; i++) {
Response.Write ('<br>a['+i+'] = ' + a[i]);
}

client:

<script language="javascript">
<%
for (var i=0; i<a.length; i++) {
Response.Write ('alert ("a['+i+'] = ' + a[i]+ '")');
}

%>
</script>

Last bit not tested as I have a seperate function called "DebugOut"
which basically does the ASP way with colors and only if on localhost.


HTH.

Al


On Fri, 9 Jan 2004 03:52:01 -0800, "josema"
<(E-Mail Removed)> wrote:

>Hi to all
>
>I have a asp page that have an array for instance:
><%
>a(0)=0
>a(1)=1
>a(2)=2
>a(3)=3
>%>
>I would like to show each element of the array with
>alerts in javascript... Do you know what its the way to
>make something like this...
>
>Thanks in advance and happy new year.
>josema


 
Reply With Quote
 
Josema
Guest
Posts: n/a
 
      01-09-2004
Sorry Dan,but my before explication was not correctly

The question is that i have an array in asp with money...

this array allways have the same number of elements, but
the value of each element is dinamic
<%
array(0)=5$
array(1)=6$
%>

and in the browser i have one like this:

<select name=x onchange=.....>
<option value=first>money1</option>
<option value=second>money2</option>
</select>

and a textbox simple

My program must do this...
If a user selects the option money1, the textbox.value
must be 5$

If a user selects the option money2, the textbox.value
must be 6$

Its like i cant connect the javascript with the asp,
cause one execute in the server and the another in the
client...


>-----Original Message-----
>
>"josema" <(E-Mail Removed)> wrote in

message
>news:0a0701c3d6a6$fdf5de90$(E-Mail Removed)...
>> Hi to all
>>
>> I have a asp page that have an array for instance:
>> <%
>> a(0)=0
>> a(1)=1
>> a(2)=2
>> a(3)=3
>> %>
>> I would like to show each element of the array with
>> alerts in javascript... Do you know what its the way to
>> make something like this...

>
>You need to write your server code into a locally held

array - excuse my JS
>if it's wrong in terms of syntax, but I tend to program

in VB and I'm not
>looking up the JS syntax )
>
>So :
> <%
>a(0)=0
> a(1)=1
> a(2)=2
> a(3)=3
> %>
><html>
><body>
><script language ="javascript">
>var aLocal(3)
>
><%
>iCounter = 0
>for (iCounter=0;iCounter<a.length;iCounter++) {
> Response.Write('aLocal(' + iCounter + ') = ' + a

(iCounter) + vbnewline
>// Whatever the Jscript equivlant is - \n ?
>}
>%>
>for(a=0;a<aLocal.length;a++) {
> alert(aLocal(a))
>}
></script>
></body>
></html>
>
>
>
>
>
>
>
>
>
>
>
>
>.
>

 
Reply With Quote
 
Harag
Guest
Posts: n/a
 
      01-09-2004

OK relooking at the OP I'm confused, are your coding ASP in VBscript
or Jscript ???

in VBscript arrays are used with rounded brackets and Jscript uses sqr
brackets
eg
VBscript: myArray(5)
Jscript: myArray[5]

The code I wrote b4 was for ASP Jscript.

so for ASP VBscript you could do this:


' direct to Page:
DIM i
for i = 0 to ubound(a)
Response.Write "<br>a("& i &") ="' & a(i));
next



<!--As clientside alerts: -->
<script language="javascript">
<%
DIM i
for i = 0 to ubound(a)
Response.Write "alert (""a("& i &") =" & a(i) & """);" ;
next

%>
</script>


HTH.
Al


On Fri, 09 Jan 2004 12:15:51 +0000, Harag
<(E-Mail Removed)> wrote:

>
>
>Alert is a CLIENT site command.
>
>so you would either have the asp code write client code... or just
>simply use Response.Write to write out the value.
>
>asp:
>
>for (var i=0; i<a.length; i++) {
> Response.Write ('<br>a['+i+'] = ' + a[i]);
>}
>
>client:
>
><script language="javascript">
><%
>for (var i=0; i<a.length; i++) {
> Response.Write ('alert ("a['+i+'] = ' + a[i]+ '")');
>}
>
>%>
></script>
>
>Last bit not tested as I have a seperate function called "DebugOut"
>which basically does the ASP way with colors and only if on localhost.
>
>
>HTH.
>
>Al
>
>
>On Fri, 9 Jan 2004 03:52:01 -0800, "josema"
><(E-Mail Removed)> wrote:
>
>>Hi to all
>>
>>I have a asp page that have an array for instance:
>><%
>>a(0)=0
>>a(1)=1
>>a(2)=2
>>a(3)=3
>>%>
>>I would like to show each element of the array with
>>alerts in javascript... Do you know what its the way to
>>make something like this...
>>
>>Thanks in advance and happy new year.
>>josema


 
Reply With Quote
 
josema
Guest
Posts: n/a
 
      01-09-2004
Its in vbscript, thanks Harag, i post a message... My
initial question was not 100% correct exposed...
Thanks
Josema
>-----Original Message-----
>
>OK relooking at the OP I'm confused, are your coding ASP

in VBscript
>or Jscript ???
>
>in VBscript arrays are used with rounded brackets and

Jscript uses sqr
>brackets
>eg
>VBscript: myArray(5)
>Jscript: myArray[5]
>
>The code I wrote b4 was for ASP Jscript.
>
>so for ASP VBscript you could do this:
>
>
>' direct to Page:
>DIM i
>for i = 0 to ubound(a)
> Response.Write "<br>a("& i &") ="' & a(i));
>next
>
>
>
><!--As clientside alerts: -->
><script language="javascript">
><%
>DIM i
>for i = 0 to ubound(a)
> Response.Write "alert (""a("& i &") =" & a(i)

& """);" ;
>next
>
>%>
></script>
>
>
>HTH.
>Al
>
>
>On Fri, 09 Jan 2004 12:15:51 +0000, Harag
><(E-Mail Removed)> wrote:
>
>>
>>
>>Alert is a CLIENT site command.
>>
>>so you would either have the asp code write client

code... or just
>>simply use Response.Write to write out the value.
>>
>>asp:
>>
>>for (var i=0; i<a.length; i++) {
>> Response.Write ('<br>a['+i+'] = ' + a[i]);
>>}
>>
>>client:
>>
>><script language="javascript">
>><%
>>for (var i=0; i<a.length; i++) {
>> Response.Write ('alert ("a['+i+'] = ' + a[i]

+ '")');
>>}
>>
>>%>
>></script>
>>
>>Last bit not tested as I have a seperate function

called "DebugOut"
>>which basically does the ASP way with colors and only

if on localhost.
>>
>>
>>HTH.
>>
>>Al
>>
>>
>>On Fri, 9 Jan 2004 03:52:01 -0800, "josema"
>><(E-Mail Removed)> wrote:
>>
>>>Hi to all
>>>
>>>I have a asp page that have an array for instance:
>>><%
>>>a(0)=0
>>>a(1)=1
>>>a(2)=2
>>>a(3)=3
>>>%>
>>>I would like to show each element of the array with
>>>alerts in javascript... Do you know what its the way

to
>>>make something like this...
>>>
>>>Thanks in advance and happy new year.
>>>josema

>
>.
>

 
Reply With Quote
 
Harag
Guest
Posts: n/a
 
      01-09-2004


see the 3 changes in your code, not tested but heading in the right
direction

HTH

Al.

On Fri, 9 Jan 2004 04:33:27 -0800, "Josema"
<(E-Mail Removed)> wrote:

>Sorry Dan,but my before explication was not correctly
>
>The question is that i have an array in asp with money...
>
>this array allways have the same number of elements, but
>the value of each element is dinamic
><%
>array(0)=5$
>array(1)=6$
>%>
>
>and in the browser i have one like this:
>
><select name=x onchange="document.form('FormNameHere').elements(' TextBoxNameHere').value = this.value; ">
><option value="<%=Array(0)%>">money1</option>
><option value="<%=Array(1)%>">money2</option>
></select>
>
>and a textbox simple
>
>My program must do this...
>If a user selects the option money1, the textbox.value
>must be 5$
>
>If a user selects the option money2, the textbox.value
>must be 6$
>
>Its like i cant connect the javascript with the asp,
>cause one execute in the server and the another in the
>client...
>
>
>>-----Original Message-----
>>
>>"josema" <(E-Mail Removed)> wrote in

>message
>>news:0a0701c3d6a6$fdf5de90$(E-Mail Removed)...
>>> Hi to all
>>>
>>> I have a asp page that have an array for instance:
>>> <%
>>> a(0)=0
>>> a(1)=1
>>> a(2)=2
>>> a(3)=3
>>> %>
>>> I would like to show each element of the array with
>>> alerts in javascript... Do you know what its the way to
>>> make something like this...

>>
>>You need to write your server code into a locally held

>array - excuse my JS
>>if it's wrong in terms of syntax, but I tend to program

>in VB and I'm not
>>looking up the JS syntax )
>>
>>So :
>> <%
>>a(0)=0
>> a(1)=1
>> a(2)=2
>> a(3)=3
>> %>
>><html>
>><body>
>><script language ="javascript">
>>var aLocal(3)
>>
>><%
>>iCounter = 0
>>for (iCounter=0;iCounter<a.length;iCounter++) {
>> Response.Write('aLocal(' + iCounter + ') = ' + a

>(iCounter) + vbnewline
>>// Whatever the Jscript equivlant is - \n ?
>>}
>>%>
>>for(a=0;a<aLocal.length;a++) {
>> alert(aLocal(a))
>>}
>></script>
>></body>
>></html>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>.
>>


 
Reply With Quote
 
Alex G
Guest
Posts: n/a
 
      01-09-2004
<%
Response.Write("<script>")
for i = 0 to UBound(a())
Response.Write "alert(""" & a(i) & """);"
Next
Response.Write("</script>")
%>

"josema" <(E-Mail Removed)> wrote in message news:<0a0701c3d6a6$fdf5de90$(E-Mail Removed)>...
> Hi to all
>
> I have a asp page that have an array for instance:
> <%
> a(0)=0
> a(1)=1
> a(2)=2
> a(3)=3
> %>
> I would like to show each element of the array with
> alerts in javascript... Do you know what its the way to
> make something like this...
>
> Thanks in advance and happy new year.
> josema

 
Reply With Quote
 
Roland Hall
Guest
Posts: n/a
 
      01-09-2004
: ><script language="javascript">

Something to note:

In ASP you define the default language:

<%@ LANGUAGE=VBScript %>

If you want to include servers-side script blocks, in any language (VBS/JS),
you have to specify the language.

<script language="jscript" runat=server>

However, on the client-side, you specify it differently since language= has
been deprecated.

<script type="text/jscript">

--
Roland

This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose.
-Technet Knowledge Base-
http://support.microsoft.com/default...&ln=EN-US&FR=0
-Technet Script Center-
http://www.microsoft.com/technet/tre...er/default.asp
-MSDN Library-
http://msdn.microsoft.com/library/default.asp


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
JavaScript or not JavaScript Mark Rae ASP .Net 36 09-09-2006 01:12 PM
href="javascript:func()" vs href="#" onclick="javascript:func()" CRON HTML 24 06-20-2006 08:05 PM
Javascript -> Applet: variable reset after method call from javascript?! mcdeveloper Java 1 06-13-2006 08:34 AM
asp.net - javascript form values interaction can asp.net read and write to nonasp forms? David Virgil Hobbs ASP .Net 0 01-06-2004 07:09 AM
ASP JavaScript versus ASP VBScript John Davis ASP General 5 09-07-2003 12:42 AM



Advertisments