Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 19th, 2005, 11:00 AM
josema
Guest
 
Posts: n/a
Default asp with javascript

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

  #2  
Old July 19th, 2005, 11:00 AM
Dan Boylett
Guest
 
Posts: n/a
Default Re: asp with javascript


"josema" <anonymous@discussions.microsoft.com> wrote in message
news:0a0701c3d6a6$fdf5de90$a401280a@phx.gbl...[color=blue]
> 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...[/color]

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>












  #3  
Old July 19th, 2005, 11:00 AM
Harag
Guest
 
Posts: n/a
Default Re: asp with javascript



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"
<anonymous@discussions.microsoft.com> wrote:
[color=blue]
>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[/color]

  #4  
Old July 19th, 2005, 11:00 AM
Harag
Guest
 
Posts: n/a
Default Re: asp with javascript


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
<harag@REMOVETHESECAPITALSsofthome.net> wrote:
[color=blue]
>
>
>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"
><anonymous@discussions.microsoft.com> wrote:
>[color=green]
>>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[/color][/color]

  #5  
Old July 19th, 2005, 11:00 AM
Josema
Guest
 
Posts: n/a
Default Re: asp with javascript

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...

[color=blue]
>-----Original Message-----
>
>"josema" <anonymous@discussions.microsoft.com> wrote in[/color]
message[color=blue]
>news:0a0701c3d6a6$fdf5de90$a401280a@phx.gbl...[color=green]
>> 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...[/color]
>
>You need to write your server code into a locally held[/color]
array - excuse my JS[color=blue]
>if it's wrong in terms of syntax, but I tend to program[/color]
in VB and I'm not[color=blue]
>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[/color]
(iCounter) + vbnewline[color=blue]
>// Whatever the Jscript equivlant is - \n ?
>}
>%>
>for(a=0;a<aLocal.length;a++) {
> alert(aLocal(a))
>}
></script>
></body>
></html>
>
>
>
>
>
>
>
>
>
>
>
>
>.
>[/color]
  #6  
Old July 19th, 2005, 11:00 AM
josema
Guest
 
Posts: n/a
Default Re: asp with javascript

Its in vbscript, thanks Harag, i post a message... My
initial question was not 100% correct exposed...
Thanks
Josema[color=blue]
>-----Original Message-----
>
>OK relooking at the OP I'm confused, are your coding ASP[/color]
in VBscript[color=blue]
>or Jscript ???
>
>in VBscript arrays are used with rounded brackets and[/color]
Jscript uses sqr[color=blue]
>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)[/color]
& """);" ;[color=blue]
>next
>
>%>
></script>
>
>
>HTH.
>Al
>
>
>On Fri, 09 Jan 2004 12:15:51 +0000, Harag
><harag@REMOVETHESECAPITALSsofthome.net> wrote:
>[color=green]
>>
>>
>>Alert is a CLIENT site command.
>>
>>so you would either have the asp code write client[/color][/color]
code... or just[color=blue][color=green]
>>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][/color][/color]
+ '")');[color=blue][color=green]
>>}
>>
>>%>
>></script>
>>
>>Last bit not tested as I have a seperate function[/color][/color]
called "DebugOut"[color=blue][color=green]
>>which basically does the ASP way with colors and only[/color][/color]
if on localhost.[color=blue][color=green]
>>
>>
>>HTH.
>>
>>Al
>>
>>
>>On Fri, 9 Jan 2004 03:52:01 -0800, "josema"
>><anonymous@discussions.microsoft.com> wrote:
>>[color=darkred]
>>>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[/color][/color][/color]
to[color=blue][color=green][color=darkred]
>>>make something like this...
>>>
>>>Thanks in advance and happy new year.
>>>josema[/color][/color]
>
>.
>[/color]
  #7  
Old July 19th, 2005, 11:00 AM
Harag
Guest
 
Posts: n/a
Default Re: asp with javascript



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"
<anonymous@discussions.microsoft.com> wrote:
[color=blue]
>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...
>
>[color=green]
>>-----Original Message-----
>>
>>"josema" <anonymous@discussions.microsoft.com> wrote in[/color]
>message[color=green]
>>news:0a0701c3d6a6$fdf5de90$a401280a@phx.gbl...[color=darkred]
>>> 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...[/color]
>>
>>You need to write your server code into a locally held[/color]
>array - excuse my JS[color=green]
>>if it's wrong in terms of syntax, but I tend to program[/color]
>in VB and I'm not[color=green]
>>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[/color]
>(iCounter) + vbnewline[color=green]
>>// Whatever the Jscript equivlant is - \n ?
>>}
>>%>
>>for(a=0;a<aLocal.length;a++) {
>> alert(aLocal(a))
>>}
>></script>
>></body>
>></html>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>.
>>[/color][/color]

  #8  
Old July 19th, 2005, 11:00 AM
Alex G
Guest
 
Posts: n/a
Default Re: asp with javascript

<%
Response.Write("<script>")
for i = 0 to UBound(a())
Response.Write "alert(""" & a(i) & """);"
Next
Response.Write("</script>")
%>

"josema" <anonymous@discussions.microsoft.com> wrote in message news:<0a0701c3d6a6$fdf5de90$a401280a@phx.gbl>...[color=blue]
> 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[/color]
  #9  
Old July 19th, 2005, 11:01 AM
Roland Hall
Guest
 
Posts: n/a
Default Re: asp with javascript

: ><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


 

Bookmarks

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles