INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

pass javascript var to asp variable

pass javascript var to asp variable

(OP)
Hello. I'm new to the forum. I'm updating a page someone else wrote; the function works on the old page but not the new page. I have done much work combining asp and javascript so I'm a little lost here.

On the first page there is a calendar control where the users picks a date.

CODE --> asp

<td align="Left"><input name="EffDate" id="DPC_date1" onfocus="showmydatepickercontrol(this);" type="text" style= "<%response.write StyleRequired%>"></td> 

There is some javascript at the top of the page that adds 1 day to the date selected.

CODE --> javascript

function setTermNotice(tb) {
	var str = tb.value;			// date is MM/DD/YYYY
	var sd = str;
	var d = new Date(sd);
	with (d) {
		setDate(getDate() + 1 );	
	}
	var sMonth = d.getMonth() + 1;		 
	sMonth = "" + sMonth;
	var sDay = d.getDate() + "" ;		
	if (sMonth.length == 1)
	{
		sMonth = "0" + sMonth;		//zero fills month if less than 2 characters
	}
	if (sDay.length == 1)			//zero fills day if less than 2 characters
	{
		sDay = "0" + sDay;
	}
	var mySpan = document.getElementById('sTermDate');
	if (mySpan)
	{ mySpan.innerHTML = sMonth + "/" + sDay + "/" + d.getFullYear(); }
	var mytp1 = document.getElementById('TermDatePlus1');
	if (mytp1)
	{ mytp1.innerHTML = sMonth + "/" + sDay + "/" + d.getFullYear(); }
} 


Below the calendar, where the user selects the initial date, is some asp code that displays the new date ('sTermDate'). The new date does show up here. I've substituted 'TermDatePlus1' for 'sTermDate' and it still shows up so I know they are both populated.

CODE --> asp

TermNotice = "All new enrollments will be effective <span id='sTermDate'>00000000</span>" 

I also need to get this date ('TermDatePlus1') into a variable that gets submitted to the next page for processing. The new date is put into a hidden variable and a Request.QueryString and sent to the next page where it's picked up by a dictionary object.

CODE --> html

<input type="hidden" name="TermDatePlus1" value=""> 

CODE --> asp

dtEffDate = Request.QueryString("TermDatePlus1") 

next page:

CODE --> asp

Set d=Server.CreateObject("Scripting.Dictionary")
d.add "dteffdate",dteffdate 

When it gets to the next page the variable is blank. I have a response.write dteffdate and it is always blank.

CODE --> asp

response.write dteffdate 
response.end 

Any help would be appreciated!

RE: pass javascript var to asp variable

Quote:

blank. I have a response.write dteffdate and it is always blank.


That's because "dteffdate" is not a variable, it is a dictionary item you you have to reference it as such.

http://www.w3schools.com/asp/asp_ref_dictionary.as...

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum

RE: pass javascript var to asp variable

(OP)
Thanks for the reply Chris.

That is odd because I can response.write any other item in the dictionary and get the correct response.

CODE --> asp

response.write strsubmitgroupid 

CODE --> asp

d.add "strsubmitgroupid",strsubmitgroupid 

strsubmitgroupid is a field displayed on the first page and put into a querystring also.

CODE --> asp

<td align="Left"><input type="text" name="SubmitGroupNum" value="<%response.write strSubmitGroupID>"> 

CODE --> asp

strSubmitGroupID = Request.QueryString("SubmitGroupNum") 

Why does dteffdate work differently? The only difference I see is that dteffdate is a hidden field and strsubmitgroupid was actually displayed on the page.

RE: pass javascript var to asp variable

Do you actually pass the variable and reset it's value on "the next page" because I don't see any code that would do that.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum

RE: pass javascript var to asp variable

(OP)
I'm not sure what you mean by "reset it's value"?

The first page shows a pending transaction and has 3000+ lines on it and it displays all of the data for the user to review. The "next page" is the action page and is about 1100 lines and just does processing. Basically it reads through the dictionary, pulls out the values it needs, submits the data to a SQL table and creates a text file with the data. It will tell the user it's been processed and they can move on to the next transaction. Since they are so large I don't really want to post them here.

RE: pass javascript var to asp variable

To have a variable that passes from 'page to page' you must have some method of storing the value at P1 and a method of reading the value and initialising the value on P2.
From the code here you store "dteffdate" in the dictionary object on P1 and I am assuming that you then store the dictionary object in a session variable so P2 can retrieve it as an object and read the values.

If that is so, do you also create a variable "dteffdate" on P2 and set it to the value that is stored in d.item("dteffdate")?

Or are these variables initialised as 'global' and "included" in all the scripts?

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum

RE: pass javascript var to asp variable

(OP)
This bit of the programming was done by someone else; who is no longer around. Not everything he did makes sense to me. All of the variables are stored in querystrings on the first page. The dictionary is on the second page. We aren't using session variables with this project and all variables are local.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close