Link to home
Start Free TrialLog in
Avatar of Manuel Marienne-Duchêne
Manuel Marienne-DuchêneFlag for France

asked on

ASP, SESSION VARIABLE AND JAVASCRIPT

I've this code for test :

window.onload=function(){
	x = document.getElementById("form_configuration");
	for (i = 0; i < x.length; i++) {
		eval('x.elements[i].value = \'<%=session("my_variable")%>\';');

	}
}

Open in new window


it's good

and code this

window.onload=function(){
	x = document.getElementById("form_configuration");
	for (i = 0; i < x.length; i++) {
		eval('x.elements[i].value = \'<%=session("' + x.elements[i].id +  '")%>\';');

	}
}

Open in new window


not good

I've a ASP session variable with the same name of x.element

Why ?

How to do that ?
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

I've a ASP session variable with the same name of x.element
Yes but are you setting x = Session('x') before using it?
Avatar of Manuel Marienne-Duchêne

ASKER

I dont understand
ASKER CERTIFIED SOLUTION
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@padas - I would tend to agree except this is what I was going on

I've a ASP session variable with the same name of x.element
x.elements[i].id

Open in new window

The above is javascript, so it isn't available till after the server and client renders the HTML.  

Which means your server will never see the value of the ID.
Many times I find the question is trying to go after a specific issue and the real solution has to do with other parts of the the page.  In this case, perhaps if you can give us an idea of what this page is doing, there may be different solution you have not thought of other then trying to mix serverside and cleintside data.