473,769 Members | 6,499 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.queryst ring("view")
if view = "" then
view = "SciLink"
else
%>
<script language="JavaS cript">
updateclasses(f orm1, 0, Student)
</script>
<%
end if

<form name=form1 method=post>
<td><span class=middleCol ContentBold>SOR T BY:</span><br>
<select multiple class="rubricCo ntent"
onchange="gotos ite(this.option s
[this.selectedIn dex].value);updatec lasses(this.for m, 0,
this.selectedIn dex)" style="backgrou nd-color:FFFFFF; border:1 solid
black; width:110;">
<option value="gradeboo k3.asp?view=Sci Link" <% if view = "SciLink"
then response.write "selected" end if %>>SCILINKS</option>
<option value="gradeboo k3.asp?view=Stu dent" <% if view = "Student"
then response.write "selected" end if %>>CLASSES</option>
</select>
</td>
</form>
Jul 20 '05 #1
7 3537
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.javas cript:
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.getEle mentById("x").v alue = val;
document.getEle mentById("y").s ubmit();
}
</script>

<button onclick="z('3.1 4')">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(t his.form, 0,this.selected Index)"
I am also send the form to the .asp page with
onchange="gotos ite(this.option s this.selectedIn dex].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="updatecl asses(this.form ,
0,this.selected Index)"">

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.javas cript:
<input type="hidden" name="test" value="updatecl asses(this.form ,
0,this.selected Index)"">


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_valu e>

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

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(t his.form, 0, this.selectedIn dex)

I assume this.form would be my form name form1
What is this.selectedIn dex? 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
72167
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 fillForm() { // split the query string into pieces var qs = location.search.substr(location.search.indexOf("?")+1); qs = qs.split("&"); alert(qs); // qs is the variable that I need to pass into a
1
2578
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:
3
14949
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) { document.images.src = eval("mt" +menu+ ".src") } alert("imgOff_hidemenu"); hideMenu=setTimeout('Hide(menu,num)',500);
2
5061
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 this particular FULL code into a MySQL field. Here's the drill: I have a timer on a PHP webpage, and i want to prevent the user from doing a
1
2423
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 GENERATED BY FUNCTION. Here'e the point: I'm writing a simple website for showing my photographs. It has a central page with many links (as many as galleries are).
2
2184
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: newWin('/vcrc/exitvcrc.jhtml&newURL=http://www.something.net/default.asp?sponID=ETC','NowLeaving','420', '200', 'no', 'auto','no');" So, pretty much, the page I'm sending the variable to think there's two variables (newURL and sponID), but...
6
5581
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 object collection and stanrd using it it starts to fall apart. Clearly there is something about javascript's usage of passing "By ref" that i am not getting. i have had a look on the web and found some examples, but i cant see why my code does not...
5
5020
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
1967
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 call that variable in another Java script. Sample script <SCRIPT LANGUAGE="JavaScript"> function GetSelectedItem() { len = document.formname.selectname.length i = 0 chosen = "none"
5
10300
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 may also open up new chat windows with other members (just not the same one). - Each chat page is opened with the member name as the window name. - When I log off from the web page, I would like all the chat windows to automatically close. I...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10045
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
9993
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
8870
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
7406
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
6672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3958
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.