Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > having an ASP variable in javascript

Reply
Thread Tools

having an ASP variable in javascript

 
 
middletree
Guest
Posts: n/a
 
      01-14-2004
I have a menu that I use on my Intranet app, and while I did try to replace
it recently, I ended up going back to it. It's built entirely with
javascript, and works great.

However, there are certain pages where I would like to be able to put an
item into a querystring for a link. That is, I might have a link which is
worded "Add to this ticket" and the hyperlink associated with that text is
along the lines of "addtoticket.asp?ticketid=1000"

I am not able to figure out how to have an ASP variable into a link built by
javascript. This is the main question. How can I have the ASP variable in a
javascript?

Because it's Inranet, I don't have the page to show you. However, I have
zipped up the two javascript files and placed them at
www.middletree.net/js.zip

Also, in this case, IE-specific code will not be a problem. 100% of users
are on IE5+


 
Reply With Quote
 
 
 
 
TomB
Guest
Posts: n/a
 
      01-14-2004
<%
'This is asp so it runs on the server

Dim aVar
aVar="1000"
%>
<script language="Javascript">
//this runs on the client, except for the <%=aVar%> part which gets
tossed in on the server
function AddToTicket()
{
window.open('theUrl.asp?id=<%=aVar%>');
}
</script>


"middletree" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I have a menu that I use on my Intranet app, and while I did try to

replace
> it recently, I ended up going back to it. It's built entirely with
> javascript, and works great.
>
> However, there are certain pages where I would like to be able to put an
> item into a querystring for a link. That is, I might have a link which is
> worded "Add to this ticket" and the hyperlink associated with that text is
> along the lines of "addtoticket.asp?ticketid=1000"
>
> I am not able to figure out how to have an ASP variable into a link built

by
> javascript. This is the main question. How can I have the ASP variable in

a
> javascript?
>
> Because it's Inranet, I don't have the page to show you. However, I have
> zipped up the two javascript files and placed them at
> www.middletree.net/js.zip
>
> Also, in this case, IE-specific code will not be a problem. 100% of users
> are on IE5+
>
>



 
Reply With Quote
 
 
 
 
Curt_C [MVP]
Guest
Posts: n/a
 
      01-14-2004
replace
addtoticket.asp?ticketid=1000
with
addtoticket.asp?ticketid=<%=YourAspVariable%>

--
Curt Christianson
Owner/Lead Developer, DF-Software
www.Darkfalz.com


"middletree" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I have a menu that I use on my Intranet app, and while I did try to

replace
> it recently, I ended up going back to it. It's built entirely with
> javascript, and works great.
>
> However, there are certain pages where I would like to be able to put an
> item into a querystring for a link. That is, I might have a link which is
> worded "Add to this ticket" and the hyperlink associated with that text is
> along the lines of "addtoticket.asp?ticketid=1000"
>
> I am not able to figure out how to have an ASP variable into a link built

by
> javascript. This is the main question. How can I have the ASP variable in

a
> javascript?
>
> Because it's Inranet, I don't have the page to show you. However, I have
> zipped up the two javascript files and placed them at
> www.middletree.net/js.zip
>
> Also, in this case, IE-specific code will not be a problem. 100% of users
> are on IE5+
>
>



 
Reply With Quote
 
middletree
Guest
Posts: n/a
 
      01-14-2004
OK, I'll try it. But that was so obvious that I didn't think it would work.


"Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
news:(E-Mail Removed)...
> replace
> addtoticket.asp?ticketid=1000
> with
> addtoticket.asp?ticketid=<%=YourAspVariable%>
>
> --
> Curt Christianson
> Owner/Lead Developer, DF-Software
> www.Darkfalz.com
>
>
> "middletree" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > I have a menu that I use on my Intranet app, and while I did try to

> replace
> > it recently, I ended up going back to it. It's built entirely with
> > javascript, and works great.
> >
> > However, there are certain pages where I would like to be able to put an
> > item into a querystring for a link. That is, I might have a link which

is
> > worded "Add to this ticket" and the hyperlink associated with that text

is
> > along the lines of "addtoticket.asp?ticketid=1000"
> >
> > I am not able to figure out how to have an ASP variable into a link

built
> by
> > javascript. This is the main question. How can I have the ASP variable

in
> a
> > javascript?
> >
> > Because it's Inranet, I don't have the page to show you. However, I have
> > zipped up the two javascript files and placed them at
> > www.middletree.net/js.zip
> >
> > Also, in this case, IE-specific code will not be a problem. 100% of

users
> > are on IE5+
> >
> >

>
>



 
Reply With Quote
 
middletree
Guest
Posts: n/a
 
      01-14-2004
Didn't work.

The link is took me to, which should have been
http://localhost/TicketLog.asp?TicketID=1000&New=notnew, was actually
http://localhost/TicketLog.asp?TicketID=<%=intTicketID%>&New=notnew

Syntax error converting the varchar value '<=strTicketID>' to a column of
data type int.

/TicketLog.asp, line 34





"Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
news:(E-Mail Removed)...
> replace
> addtoticket.asp?ticketid=1000
> with
> addtoticket.asp?ticketid=<%=YourAspVariable%>
>
> --
> Curt Christianson
> Owner/Lead Developer, DF-Software
> www.Darkfalz.com
>
>
> "middletree" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > I have a menu that I use on my Intranet app, and while I did try to

> replace
> > it recently, I ended up going back to it. It's built entirely with
> > javascript, and works great.
> >
> > However, there are certain pages where I would like to be able to put an
> > item into a querystring for a link. That is, I might have a link which

is
> > worded "Add to this ticket" and the hyperlink associated with that text

is
> > along the lines of "addtoticket.asp?ticketid=1000"
> >
> > I am not able to figure out how to have an ASP variable into a link

built
> by
> > javascript. This is the main question. How can I have the ASP variable

in
> a
> > javascript?
> >
> > Because it's Inranet, I don't have the page to show you. However, I have
> > zipped up the two javascript files and placed them at
> > www.middletree.net/js.zip
> >
> > Also, in this case, IE-specific code will not be a problem. 100% of

users
> > are on IE5+
> >
> >

>
>



 
Reply With Quote
 
Mark Schupp
Guest
Posts: n/a
 
      01-14-2004
The files where you want to substitute variables are JS files and are not
processed by ASP. There are a couple of possibilities.

1. make the js files .asp files and include asp code to set the
variables.

2. add a javacript variable declaration to the asp page before including
the script file. then use that variable in the script file.

....
<script language="javascript">
var strTicketID = "<%=YourAspVariable%>";
</script>

<script language="javascript" src="menu.js"></script>
....

in menu.js

self.location="addtoticket.asp?ticketid=" + strTicketID;

--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com


"middletree" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Didn't work.
>
> The link is took me to, which should have been
> http://localhost/TicketLog.asp?TicketID=1000&New=notnew, was actually
> http://localhost/TicketLog.asp?TicketID=<%=intTicketID%>&New=notnew
>
> Syntax error converting the varchar value '<=strTicketID>' to a column of
> data type int.
>
> /TicketLog.asp, line 34
>
>
>
>
>
> "Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
> news:(E-Mail Removed)...
> > replace
> > addtoticket.asp?ticketid=1000
> > with
> > addtoticket.asp?ticketid=<%=YourAspVariable%>
> >
> > --
> > Curt Christianson
> > Owner/Lead Developer, DF-Software
> > www.Darkfalz.com
> >
> >
> > "middletree" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > I have a menu that I use on my Intranet app, and while I did try to

> > replace
> > > it recently, I ended up going back to it. It's built entirely with
> > > javascript, and works great.
> > >
> > > However, there are certain pages where I would like to be able to put

an
> > > item into a querystring for a link. That is, I might have a link which

> is
> > > worded "Add to this ticket" and the hyperlink associated with that

text
> is
> > > along the lines of "addtoticket.asp?ticketid=1000"
> > >
> > > I am not able to figure out how to have an ASP variable into a link

> built
> > by
> > > javascript. This is the main question. How can I have the ASP variable

> in
> > a
> > > javascript?
> > >
> > > Because it's Inranet, I don't have the page to show you. However, I

have
> > > zipped up the two javascript files and placed them at
> > > www.middletree.net/js.zip
> > >
> > > Also, in this case, IE-specific code will not be a problem. 100% of

> users
> > > are on IE5+
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Curt_C [MVP]
Guest
Posts: n/a
 
      01-14-2004
you'll have to show a few more lines of code from this asp

--
Curt Christianson
Owner/Lead Developer, DF-Software
www.Darkfalz.com


"middletree" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Didn't work.
>
> The link is took me to, which should have been
> http://localhost/TicketLog.asp?TicketID=1000&New=notnew, was actually
> http://localhost/TicketLog.asp?TicketID=<%=intTicketID%>&New=notnew
>
> Syntax error converting the varchar value '<=strTicketID>' to a column of
> data type int.
>
> /TicketLog.asp, line 34
>
>
>
>
>
> "Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
> news:(E-Mail Removed)...
> > replace
> > addtoticket.asp?ticketid=1000
> > with
> > addtoticket.asp?ticketid=<%=YourAspVariable%>
> >
> > --
> > Curt Christianson
> > Owner/Lead Developer, DF-Software
> > www.Darkfalz.com
> >
> >
> > "middletree" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > I have a menu that I use on my Intranet app, and while I did try to

> > replace
> > > it recently, I ended up going back to it. It's built entirely with
> > > javascript, and works great.
> > >
> > > However, there are certain pages where I would like to be able to put

an
> > > item into a querystring for a link. That is, I might have a link which

> is
> > > worded "Add to this ticket" and the hyperlink associated with that

text
> is
> > > along the lines of "addtoticket.asp?ticketid=1000"
> > >
> > > I am not able to figure out how to have an ASP variable into a link

> built
> > by
> > > javascript. This is the main question. How can I have the ASP variable

> in
> > a
> > > javascript?
> > >
> > > Because it's Inranet, I don't have the page to show you. However, I

have
> > > zipped up the two javascript files and placed them at
> > > www.middletree.net/js.zip
> > >
> > > Also, in this case, IE-specific code will not be a problem. 100% of

> users
> > > are on IE5+
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
middletree
Guest
Posts: n/a
 
      01-14-2004
Comments below:

"Mark Schupp" <(E-Mail Removed)> wrote in message
news:eg2#(E-Mail Removed)...
> The files where you want to substitute variables are JS files and are not
> processed by ASP.


That was my point in the OP. Guess I didn't communicate it well.

>There are a couple of possibilities.
>> 1. make the js files .asp files and include asp code to set the

variables.
>

I have no idea how to do this, or what you mean, exactly.

> 2. add a javacript variable declaration to the asp page before

including
> the script file. then use that variable in the script file.
>
> ...
> <script language="javascript">
> var strTicketID = "<%=YourAspVariable%>";
> </script>
>
> <script language="javascript" src="menu.js"></script>
> ...
>
> in menu.js
>
> self.location="addtoticket.asp?ticketid=" + strTicketID;
>


Hmm, this looks like something I could do. Let me check and I'll post my
results.

thanks very much!



 
Reply With Quote
 
middletree
Guest
Posts: n/a
 
      01-14-2004
Nope. Didn't work.

It gave me a link to
http://localhost/TicketLog.asp?TicketID=+strTicketID


"Mark Schupp" <(E-Mail Removed)> wrote in message
news:eg2#(E-Mail Removed)...
> The files where you want to substitute variables are JS files and are not
> processed by ASP. There are a couple of possibilities.
>
> 1. make the js files .asp files and include asp code to set the
> variables.
>
> 2. add a javacript variable declaration to the asp page before

including
> the script file. then use that variable in the script file.
>
> ...
> <script language="javascript">
> var strTicketID = "<%=YourAspVariable%>";
> </script>
>
> <script language="javascript" src="menu.js"></script>
> ...
>
> in menu.js
>
> self.location="addtoticket.asp?ticketid=" + strTicketID;
>
> --
> Mark Schupp
> Head of Development
> Integrity eLearning
> www.ielearning.com
>
>
> "middletree" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > Didn't work.
> >
> > The link is took me to, which should have been
> > http://localhost/TicketLog.asp?TicketID=1000&New=notnew, was actually
> > http://localhost/TicketLog.asp?TicketID=<%=intTicketID%>&New=notnew
> >
> > Syntax error converting the varchar value '<=strTicketID>' to a column

of
> > data type int.
> >
> > /TicketLog.asp, line 34
> >
> >
> >
> >
> >
> > "Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
> > news:(E-Mail Removed)...
> > > replace
> > > addtoticket.asp?ticketid=1000
> > > with
> > > addtoticket.asp?ticketid=<%=YourAspVariable%>
> > >
> > > --
> > > Curt Christianson
> > > Owner/Lead Developer, DF-Software
> > > www.Darkfalz.com
> > >
> > >
> > > "middletree" <(E-Mail Removed)> wrote in message
> > > news:(E-Mail Removed)...
> > > > I have a menu that I use on my Intranet app, and while I did try to
> > > replace
> > > > it recently, I ended up going back to it. It's built entirely with
> > > > javascript, and works great.
> > > >
> > > > However, there are certain pages where I would like to be able to

put
> an
> > > > item into a querystring for a link. That is, I might have a link

which
> > is
> > > > worded "Add to this ticket" and the hyperlink associated with that

> text
> > is
> > > > along the lines of "addtoticket.asp?ticketid=1000"
> > > >
> > > > I am not able to figure out how to have an ASP variable into a link

> > built
> > > by
> > > > javascript. This is the main question. How can I have the ASP

variable
> > in
> > > a
> > > > javascript?
> > > >
> > > > Because it's Inranet, I don't have the page to show you. However, I

> have
> > > > zipped up the two javascript files and placed them at
> > > > www.middletree.net/js.zip
> > > >
> > > > Also, in this case, IE-specific code will not be a problem. 100% of

> > users
> > > > are on IE5+
> > > >
> > > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
middletree
Guest
Posts: n/a
 
      01-14-2004
Well, there's no ASP, really. I mean, this menu is built entirely in js. I
have the js you can look at in the zip file I mentioned earlier, but on the
ASP page, I just have the <script> code which points to the external js
file.


"Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
news:(E-Mail Removed)...
> you'll have to show a few more lines of code from this asp
>
> --
> Curt Christianson
> Owner/Lead Developer, DF-Software
> www.Darkfalz.com
>
>
> "middletree" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > Didn't work.
> >
> > The link is took me to, which should have been
> > http://localhost/TicketLog.asp?TicketID=1000&New=notnew, was actually
> > http://localhost/TicketLog.asp?TicketID=<%=intTicketID%>&New=notnew
> >
> > Syntax error converting the varchar value '<=strTicketID>' to a column

of
> > data type int.
> >
> > /TicketLog.asp, line 34
> >
> >
> >
> >
> >
> > "Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
> > news:(E-Mail Removed)...
> > > replace
> > > addtoticket.asp?ticketid=1000
> > > with
> > > addtoticket.asp?ticketid=<%=YourAspVariable%>
> > >
> > > --
> > > Curt Christianson
> > > Owner/Lead Developer, DF-Software
> > > www.Darkfalz.com
> > >
> > >
> > > "middletree" <(E-Mail Removed)> wrote in message
> > > news:(E-Mail Removed)...
> > > > I have a menu that I use on my Intranet app, and while I did try to
> > > replace
> > > > it recently, I ended up going back to it. It's built entirely with
> > > > javascript, and works great.
> > > >
> > > > However, there are certain pages where I would like to be able to

put
> an
> > > > item into a querystring for a link. That is, I might have a link

which
> > is
> > > > worded "Add to this ticket" and the hyperlink associated with that

> text
> > is
> > > > along the lines of "addtoticket.asp?ticketid=1000"
> > > >
> > > > I am not able to figure out how to have an ASP variable into a link

> > built
> > > by
> > > > javascript. This is the main question. How can I have the ASP

variable
> > in
> > > a
> > > > javascript?
> > > >
> > > > Because it's Inranet, I don't have the page to show you. However, I

> have
> > > > zipped up the two javascript files and placed them at
> > > > www.middletree.net/js.zip
> > > >
> > > > Also, in this case, IE-specific code will not be a problem. 100% of

> > users
> > > > are on IE5+
> > > >
> > > >
> > >
> > >

> >
> >

>
>



 
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
Passing a variable value from Javascript to asp.net server variable shil ASP .Net 2 01-02-2007 09:33 PM
passing data from javascript variable to asp variable. Steve Cosh ASP General 1 11-18-2005 04:15 AM
how to get javascript variable value into asp variable tnhoe Javascript 4 04-21-2005 06:32 PM
passing javascript variable into asp variable using vbscript Jonas Daunoravicius Javascript 5 07-17-2003 04:54 AM
passing javascript variable into asp variable using vbscript Jonas Daunoravicius ASP General 5 07-17-2003 04:54 AM



Advertisments