473,624 Members | 2,234 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

passing javascript variable into asp variable using vbscript

The subject pretty much sums up what I need to do. Here is what I
have so far, but still can't figure out how to get it working:

<script language="javas cript" type="text/javascript">
function fillForm()
{
// split the query string into pieces
var qs = location.search .substr(locatio n.search.indexO f("?")+1);
qs = qs.split("&");
alert(qs); // qs is the variable that I need to pass into a
// vbscript var. This actually works up to here.
'<%the_name%>' = qs // this line does not work, but is what I need
// to do.
}
</script>
later in the code:
<%
Response.write ("<script>fillF orm();</script>")
Response.write( "This is the variable: " & the_name)
%>

On the page it obviously comes up as "This is the variable: " and that
is it...blank for the_name.

I need to use javascript to get the variables out of the url, such as:
http://www.x.com/test.asp?Dell%20Computer%20Corp
qs will then end up being "Dell Computer Corp" and I need to make a
vbscript variable to also be that so I can query/load/etc certain
stuff in asp to display on the site.

Thanks for your help!

- Jonas
Jul 19 '05 #1
7 72141
I don't think it is possible, because the vbscript (the server code) will
always be executed before the page ever reaches the browser where the
javascript is executed. Please correct me if I am wrong. I wish someone
would post a website or write a book on the subject of communication between
server-side and client-side scripts.

Phil

"Jonas Daunoravicius" <Jd************ @questarcapital .com> wrote in message
news:fa******** *************** **@posting.goog le.com...
The subject pretty much sums up what I need to do. Here is what I
have so far, but still can't figure out how to get it working:

<script language="javas cript" type="text/javascript">
function fillForm()
{
// split the query string into pieces
var qs = location.search .substr(locatio n.search.indexO f("?")+1);
qs = qs.split("&");
alert(qs); // qs is the variable that I need to pass into a
// vbscript var. This actually works up to here.
'<%the_name%>' = qs // this line does not work, but is what I need
// to do.
}
</script>
later in the code:
<%
Response.write ("<script>fillF orm();</script>")
Response.write( "This is the variable: " & the_name)
%>

On the page it obviously comes up as "This is the variable: " and that
is it...blank for the_name.

I need to use javascript to get the variables out of the url, such as:
http://www.x.com/test.asp?Dell%20Computer%20Corp
qs will then end up being "Dell Computer Corp" and I need to make a
vbscript variable to also be that so I can query/load/etc certain
stuff in asp to display on the site.

Thanks for your help!

- Jonas

Jul 19 '05 #2
I don't think it is possible, because the vbscript (the server code) will
always be executed before the page ever reaches the browser where the
javascript is executed. Please correct me if I am wrong. I wish someone
would post a website or write a book on the subject of communication between
server-side and client-side scripts.

Phil

"Jonas Daunoravicius" <Jd************ @questarcapital .com> wrote in message
news:fa******** *************** **@posting.goog le.com...
The subject pretty much sums up what I need to do. Here is what I
have so far, but still can't figure out how to get it working:

<script language="javas cript" type="text/javascript">
function fillForm()
{
// split the query string into pieces
var qs = location.search .substr(locatio n.search.indexO f("?")+1);
qs = qs.split("&");
alert(qs); // qs is the variable that I need to pass into a
// vbscript var. This actually works up to here.
'<%the_name%>' = qs // this line does not work, but is what I need
// to do.
}
</script>
later in the code:
<%
Response.write ("<script>fillF orm();</script>")
Response.write( "This is the variable: " & the_name)
%>

On the page it obviously comes up as "This is the variable: " and that
is it...blank for the_name.

I need to use javascript to get the variables out of the url, such as:
http://www.x.com/test.asp?Dell%20Computer%20Corp
qs will then end up being "Dell Computer Corp" and I need to make a
vbscript variable to also be that so I can query/load/etc certain
stuff in asp to display on the site.

Thanks for your help!

- Jonas

Jul 19 '05 #3
But surely if you are using ASP you can do the following:

URL : http://www.testsite.com/test.asp?Com...omputer%20Corp

<% varCompany = Request.QuerySt ring("Company") %>
to extract from the URL to variable varCompany

and where you need to place the variable:

<%= varCompany %>

all in ASP
The only bit using VB of Javascript is the creation of the URL (which here I
am creating from items in a form, in the case of someone NOT using the
submit button!) And then reloading the page.

NewURL = "location.asp?" ;
var EleNum = 0;
var EleNumMx = document.plform .elements.lengt h;
do {
if (document.plfor m[EleNum].type == "select-one") {
if (document.plfor m[EleNum].selectedIndex != 0) {
NewURL += document.plform[EleNum].name + "=" +
document.plform[EleNum].value + "&";
}
}
if(document.plf orm[EleNum].type == "text") {
if (document.plfor m[EleNum].value != 0 ) {
NewURL += document.plform[EleNum].name + "=" +
document.plform[EleNum].value + "&";
}
}
if(document.plf orm[EleNum].type == "textarea") {
if (document.plfor m[EleNum].value != 0 ) {
NewURL += document.plform[EleNum].name + "=" +
document.plform[EleNum].value + "&";
}
}
} while(++EleNum < EleNumMx);
window.location =NewURL;

Hope this helps

John Dobson

"AlwaysLearning " <ru****@nwlink. com> wrote in message
news:tM******** *********@rwcrn sc52.ops.asp.at t.net...
I don't think it is possible, because the vbscript (the server code) will
always be executed before the page ever reaches the browser where the
javascript is executed. Please correct me if I am wrong. I wish someone
would post a website or write a book on the subject of communication between server-side and client-side scripts.

Phil

"Jonas Daunoravicius" <Jd************ @questarcapital .com> wrote in message
news:fa******** *************** **@posting.goog le.com...
The subject pretty much sums up what I need to do. Here is what I
have so far, but still can't figure out how to get it working:

<script language="javas cript" type="text/javascript">
function fillForm()
{
// split the query string into pieces
var qs = location.search .substr(locatio n.search.indexO f("?")+1);
qs = qs.split("&");
alert(qs); // qs is the variable that I need to pass into a
// vbscript var. This actually works up to here.
'<%the_name%>' = qs // this line does not work, but is what I need
// to do.
}
</script>
later in the code:
<%
Response.write ("<script>fillF orm();</script>")
Response.write( "This is the variable: " & the_name)
%>

On the page it obviously comes up as "This is the variable: " and that
is it...blank for the_name.

I need to use javascript to get the variables out of the url, such as:
http://www.x.com/test.asp?Dell%20Computer%20Corp
qs will then end up being "Dell Computer Corp" and I need to make a
vbscript variable to also be that so I can query/load/etc certain
stuff in asp to display on the site.

Thanks for your help!

- Jonas


Jul 19 '05 #4
I had actually figured out using what you Richard and John mentioned
yesterday late afternoon. You know how it is when you work on
something for hours and hours and then all of a sudden you just get it
to work! :) What you guys said makes sense though and my problem was
that I didn't know you could do all of that just in vbscript. It even
ends up being cleaner also. All I ended up doing, just like you guys
said is:

<a href=""tier2.as p?prod=" & i & """>" & i & "</a>
where i is a vbscript variable from a database

and then in the next page:
the_name = request.queryst ring("prod")

prod has %20 for spaces and the_name just has spaces. It is exactly
what I was looking for.

Thanks guys for you input.

- Jonas
Jul 19 '05 #5
To get the whole query string:

<%
the_name = Request.QuerySt ring()
%>

You can pass it to client but not the other way around:

<script language="javas cript">
var the_name = ""
</script>
<%
Dim the_name
the_name = Request.QuerySt ring()
Response.write( "the name is " & the_name)
Response.write( "<script>the_na me=""" & the_name & """;</script>")
%>
<script language="javas cript">
alert(the_name)
</script>

--
Mike S.
Optimal Systems www.oscorp.com
"Jonas Daunoravicius" <Jd************ @questarcapital .com> wrote in message
news:fa******** *************** ***@posting.goo gle.com...
I just noticed that if "&" is passed, after you do a querysting, it
drops everything passed the "&" even though vbscript variables can
hold & inside.

For instance, if the URL is www.x.asp/?prod="dell%20& %20ibm"
then if you do this on the next page:
the_name = request.queryst ring("prod")
it will only come up as "dell" instead of "dell & ibm"

Everything else seems to work fine, but this. Anyone have a
suggestion in how to avoid this?

Thanks

- Jonas

Jul 19 '05 #6
Mike, thanks so much...that is even better now cause now all I needed to do is:

the_name = Replace(the_nam e, "%20", " ")

and I get exactly what I want!

Thanks for all of your inputs...have a good July 4th.

- Jonas
Jul 19 '05 #7
Alternatively use the javascript escape function to encode your "&" into a
%Code. Then unescape it before using it.

Peter.

"Jonas Daunoravicius" <Jd************ @questarcapital .com> wrote in message
news:fa******** *************** ***@posting.goo gle.com...
Mike, thanks so much...that is even better now cause now all I needed to do is:
the_name = Replace(the_nam e, "%20", " ")

and I get exactly what I want!

Thanks for all of your inputs...have a good July 4th.

- Jonas

Jul 19 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2570
by: Patrice | last post by:
Hi, I'm trying to use a javascript function passing a vb variable. I don't understand why it doesn't work. Can someone help me? Thanks in advance. Here is my javascript function used to show a text:
1
4549
by: Scott | last post by:
I have an XML Document in a format like: <Variable name="Bob">ABCDEFG</Variable> <Variable name="Steve">QWERTYUI</Variable> <Variable name="John">POIUYTR</Variable> <Variable name="Tim">ZXCVBNM</Variable> <Function id="1"> <Parameter type="String">Bob</Parameter> <Parameter type="String">Steve</Parameter>
6
16138
by: | last post by:
I have MyEnumeratedSet { ... some values go here ... } I have a variable that is defined as MyEnumeratedSet MyVariable; I have a function that needs to be able to set a variable by Ref MyFunction(ref System.Enum Parameter) { ..... Parameter has to be set here } so I have tried calling it by MyFunction(ref (Enum) MyVariable); unfortunately this yields compiler errors and it seems like there is no way
1
9123
by: Machi | last post by:
let say i have a web form with a button on it ... when i click the button, it will pop up one small window to allow me to save a pdf file, everything is done using code behind as below ... however, in javascript, i have set a global variable as a flag to indicate the number of times user click the buttion (let say flagNoOfClick), when user clicks the button once, it will set the flag (flagNoOfClick) to "true" (by using javascript). So, when user...
0
1272
by: csgraham74 | last post by:
Hi guys, I am writing an application in asp.net but im attempting to write some client side validation. I have most of this working but i am having trouble reading cookies set in asp.net using vbscript on the client side. Luckily im in a controlled browser environment therefore i can use vbscript. I understood that all cookies were client side - i therefore dont understand why i cant read them. i have tried the following code but it...
0
1538
by: neon123 | last post by:
i am using a sql loader to load data into oracle 8. i am using vbscript to run the sql loader. i need to pass username and password entered through vbscript ,,into the visual basic application . how can i do that ? i basically need to communicate between vbscript file and vb application.
3
5582
by: TheLymner | last post by:
I have, what I believe, is a rather simple question. However, I cannot find the answer anywhere on the web nor in any of the library of xml or javascript/asp books available. How do I pass and store an xml element data (an interger) into a javascript/asp variable? I am not going to display the data (that I can do easily), rather the data is going to used to deteremine how the rest of the parent data is going to be displayed in any of 90...
5
4387
by: meenu_susi | last post by:
hi all Could you please help me out i creating folder using vbscript.. I have used the following code... <SCRIPT LANGUAGE="VBScript"> <!-- Option Explicit
5
7506
Soniad
by: Soniad | last post by:
Hello, I want to include asp file within vbscript, this file name i am taking in variable . and when i use this variable in the include tag outside delimiters(<%%>), it does not work, <%Dim AllocPath AllocPath = "SchemeAllocation/"&Trim(lcase(ProductName))&"/QuotaAlloc.asp" %> <!-- #include file=<%=AllocPath %>-->
5
8086
by: asdasd10 | last post by:
It is possible create Seasson variable (ASP) through VBscript?
0
8242
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8629
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8341
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8488
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7170
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6112
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4084
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4183
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1793
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.