Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help: passing variables from JavaScript to ASP

Status
Not open for further replies.

bugeditor

Technical User
Oct 9, 2001
44
IN
Hi,
I have an ASP page with following javascript client code to calculate height and width of a picture file

<script language=&quot;javascript&quot;>
function CalPictureSize(myUrl)
{

var myImage = new Image();
myImage.src=myUrl;

var imgHeight = myImage.height;
var imgWidth = myImage.width;

if (imgHeight > 300)
{
imgHeight=300;
}
else
{
imgHeight=imgHeight;
}

if (imgWidth > 500)
{
imgWidth=500;
}
else
{
imgWidth=imgWidth;
}

&quot;<%session(&quot;height&quot;)=&quot; + imgHeight + &quot;%>&quot;
&quot;<%session(&quot;width&quot;)=&quot; + imgWidth + &quot;%>&quot;
}
</script>

Iam able to calculate ht and width smoothly..But, I want ht and width to be carried to next page and So i am trying to fetch them to session variables..

But Iam getting put as just strings imgHeight, imgWidth

can anybody help to solve this problem

thanks
 
Do the calc's and move them to hidden fields. On the submit of the form you'll have the values to do with what you want in the hidden fields....
 
How do you link to the next page? Could you use javascript to redirect the browser and append the variables as querystrings

eg

window.location.href=eval(&quot;mynextpage.asp?imgheight=&quot;+imgheight+&quot;, imgwidth=&quot;+imgwidth);

or something like that and then request them on the next page with the asp using

dim height
height = request.querystring (&quot;imgheight&quot;)

the syntax may not be exactly right im still finding my feet with asp but play around with it and you should be able to get it working. good luck.

rob
 
Hi,
Please see the above code and tell me how to pass javascript variable imgHeight and imgWidth to session variables..basically syntax..That is what my requirement
because I will accessing widths and heights in many asp pages..

Thanks
 
Like they say, you can't do it without communicating with the server - meaning a form or link - why can't you read the files server-side and get the size?

[bb]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top