473,412 Members | 5,385 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

Passing variable to ASP with javascript

I have two events in a form that I am passing. One is to a javascript
function, the other is to the same .asp page only with another action
to show different data.

Onchange is calls the function updateclasses, which in turn reloads
another drop-down list. It also reloads the .asp page, which
refreshes the data. My problem is that it refreshes the second
drop-down briefly, until the page reloads, but then resets the form.
How do i pass this data to the .asp?

I thought in the .asp, I could just do something simple like the
following, but wasn't sure of the correct syntax. is there a better
way?

view = request.querystring("view")
if view = "" then
view = "SciLink"
else
%>
<script language="JavaScript">
updateclasses(form1, 0, Student)
</script>
<%
end if

<form name=form1 method=post>
<td><span class=middleColContentBold>SORT BY:</span><br>
<select multiple class="rubricContent"
onchange="gotosite(this.options
[this.selectedIndex].value);updateclasses(this.form, 0,
this.selectedIndex)" style="background-color:FFFFFF; border:1 solid
black; width:110;">
<option value="gradebook3.asp?view=SciLink" <% if view = "SciLink"
then response.write "selected" end if %>>SCILINKS</option>
<option value="gradebook3.asp?view=Student" <% if view = "Student"
then response.write "selected" end if %>>CLASSES</option>
</select>
</td>
</form>
Jul 20 '05 #1
7 3506
Dave A wrote:
I have two events in a form that I am passing. One is to a javascript
function, the other is to the same .asp page only with another action
to show different data.

Onchange is calls the function updateclasses, which in turn reloads
another drop-down list. It also reloads the .asp page, which
refreshes the data. My problem is that it refreshes the second
drop-down briefly, until the page reloads, but then resets the form.
How do i pass this data to the .asp?


Why not have the Javascript write the data to a hidden form field(s) then grab
the POST'ed value in the ASP code?
Jul 20 '05 #2
Well, that makes sense. I'm new to javascript. How do you write to a
hidden field?

Where do I put it so the onchange still occurs?

Thanks again

Dave
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #3
Dave A wrote on 20 jan 2004 in comp.lang.javascript:
I have two events in a form that I am passing. One is to a javascript
function, the other is to the same .asp page only with another action
to show different data.


ASP can be written in javascript, so that would be implicit.
ASP does not equal vbscript, that can be clientside too [in IE]

Do you want to send a clientside value to serverside?

============= test.asp ===============

The value sent to serverside was:
<% = request.form("x") %>

<form method=post id="y">
<input type=hidden id="x" name="x">
</form>

<script>
function z(val){
document.getElementById("x").value = val;
document.getElementById("y").submit();
}
</script>

<button onclick="z('3.14')">3.14</button>
<button onclick="z('Hi')">Hi</button>
<button onclick="z('Bye')">Bye</button>
=========================================

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #4

On submitting the form, I am currently doing two things.

Attempting to update a second selection box with the following function
updateclasses(this.form, 0,this.selectedIndex)"
I am also send the form to the .asp page with
onchange="gotosite(this.options this.selectedIndex].value);

<form name=form1 method=post>

Currently, I am doing both of these in the onchange event. If I pass it
to a hidden field, a request it on the page load, what do I put in the
hidden field?

<input type="hidden" name="test" value="updateclasses(this.form,
0,this.selectedIndex)"">

Thanks

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #5
Dave Anderson wrote on 20 jan 2004 in comp.lang.javascript:
<input type="hidden" name="test" value="updateclasses(this.form,
0,this.selectedIndex)"">


You cannot code-"run" an html value

Please explain what you are doing serverside and what clientside, primarily
to yourself and also to us. I suspect you are mixing both.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #6
Dave Anderson wrote:
Well, that makes sense. I'm new to javascript. How do you write to a
hidden field?

Where do I put it so the onchange still occurs?

Thanks again

Dave
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Put this inside a form, and replace the name and value values:
<input type=hidden name=some_name value=some_value>

Brian
Jul 20 '05 #7
'<input type=hidden name=some_name value=some_value>
'

This I completely understand. What I don't understand, due to my lack of
knowledge with javascript is what are those values? Currently, I am
calling this function with an onchange event. How do I know what the
function is passing?

updateclasses(this.form, 0, this.selectedIndex)

I assume this.form would be my form name form1
What is this.selectedIndex? The values of my options or their names?

Also, once I request the variable, I assume I can just recall the
function after the page loads?

I apreciate everyone's patience and help with this. I may just be
confusing the issue!

Dave


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #8

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

Similar topics

7
by: Jonas Daunoravicius | last post by:
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="javascript" type="text/javascript"> function...
1
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...
3
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) {...
2
by: RootShell | last post by:
Hello First of all i know that PHP is a server side, and JavaScript is a Client side programming language, but i need to know if there is any way i can add the variable "countDownInterval" from...
1
by: cirillo_curiosone | last post by:
Hi, i'm new to javascript. I started studing it on the web few weeks ago, but still haven't been able to solve one big problem: HOT TO PASS VALUES FROM A SCRIPT VARIABLE TO A CHILD HTML...
2
by: brianwmunz | last post by:
Hi, I'm having a problem passing a variable through a URL because the variable is supposed to hold a URL that has a variable of its own. Here is an idea of what I'm trying to do: href="javascript:...
6
by: ged | last post by:
Hi, i am a oo (c#) programmer, and have not used javascript for a while and i cant work out how javascript manages its references. Object References work for simple stuff, but once i have an...
5
by: sfeher | last post by:
Hi All, I need to call a function(loaded with appendChild) for which I have the name as a string. .... var fnName = 'fn1'; var call = fnName + '('+ param +' )'; eval(call);
2
satterfieldben
by: satterfieldben | last post by:
I have a newbie question about passing variables between functions. I am wanting to use a drop down box to select a value. Then base on which was selected, it would create a variable and I would...
5
by: aelred | last post by:
I have a web page where a member can open up a chat window (child window) with another member. - From there the member can also navigate to other web pages. - From other pages in the site, they...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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...
0
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...
0
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,...

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.