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
 
Hmmmm. I have looked at your javascript, and noticed a few errors:
Code:
<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;
        }

/* Replace this:        
        &quot;<%session(&quot;height&quot;)=&quot; + imgHeight + &quot;%>&quot;
        &quot;<%session(&quot;width&quot;)=&quot; + imgWidth + &quot;%>&quot;
*/
// With this:
	document.write('<'+'% session(&quot;height&quot;)='+imgHeight+' %'+'>');
	document.write('<'+'% session(&quot;width&quot;)='+imgWidth+' %'+'>');

}
</script>

I'm not sure if this method of doing it will work, though _________________
Bixarrio
e = m * (c ^ 2)
 
Hi,
its not working..actually I will call this method as below

<a href==&quot;
<img src=&quot;onclick='CalPictureSize(window.event.srcElement.src)' Height=&quot;75&quot; Width=&quot;75&quot;>
</a>

so If I put above code now it doesn't even goto href page..

anybody please help with syntax how to pass java variables to asp session variables

thanks
 
Hi,
its not working..actually I will call this method as below

<a href=&quot;
<img src=&quot;onclick='CalPictureSize(window.event.srcElement.src)' Height=&quot;75&quot; Width=&quot;75&quot;>

</a>

so If I put above code now it doesn't even goto href page..

anybody please help with syntax how to pass java variables to asp session variables

thanks
 
What are you trying to do? If I knew, I might be able to help. _________________
Bixarrio
e = m * (c ^ 2)
 
Hi,
I have table cell of thumbnails each dynamically associated with a href..

say for now here I have for a tbel cell..

<a href=&quot;bigpicture.asp?PicName=mypicDir/mygif.gif&quot;>

<img src=&quot;PicName=mypicDir/mygif.gif&quot;
onclick='CalPictureSize(window.event.srcElement.src)'>

</a>

I will be invoking bigpicture.asp and then get the directory name. picturename from querystiing and display it

so before displaying it i wanted to calculate width & height of gif file and pass to the bigpicture.asp and other than using querystring and therefore using session variables..

So on image click before(i.e. on table cell click) before moving to href location Iam calling this

<img src=&quot;PicName=mypicDir/mygif.gif&quot;
onclick='CalPictureSize(window.event.srcElement.src)'>

which passes url of image to calculate dimensiond and send it to bigpicture.asp here paramater result is..i.e.

window.event.srcElement.src =
=&quot;http//myserver/mypicfir/mygif.gif&quot;>

Its working file..Iam getting dimensiond but unable to pass the same to bigpicture.asp with session variables.

Hope this gives u some idea..

Thanks
 
Why don't you calculate the width and height in bigpicture.asp? _________________
Bixarrio
e = m * (c ^ 2)
 
Hi,
Can anybody please help me with snippet..Just..Howto pass client side javascript variables to asp session variables..

Say I have following
<script language=javascript>

Myfunc(){
var myvar1 = x;
var myvar2 = y;

// I want them here to be trapped into session variables
//above say myvar1 into session(&quot;myvar1&quot;) and myvar2 into session(&quot;myvar2&quot;)


}

Is it possible..If so can anybody helpcan anybody help

regards



 
Hi,
Can anybody please help me with snippet..Just..Howto pass client side javascript variables to asp session variables..

Say I have following
<script language=javascript>

Myfunc(){
var myvar1 = x;
var myvar2 = y;

// I want them here to be trapped into session variables
//above say myvar1 into session(&quot;myvar1&quot;) and myvar2 into session(&quot;myvar2&quot;)


}

</script>
Is it possible..If so can anybody helpcan anybody help

regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top