lehula Posted August 15, 2007 Share Posted August 15, 2007 I'm looking around and it looks like there is lots of good info on pulling a var from php and using it in javascript, but no the other way around. All the info I can find says to just use hidden input boxes to hold the data, then post them with a submit button. But I have like 40 images, and I want to store their 'left' 'top' width' height'. Thats a lot of hidden input boxes to write (160+). It would be nice not to have those html'd into my script. Is there anyway to get the image height and set it as php data without a input box? Example: NOT THIS -----> <form method="post"> <input style="display:none" name="some image height"> <input submit> </form> -------------------------------------------------------------------- THIS -------> document.getElementById("some image").height = $post_imageheight[]; I'm not sure if I explained this clearly enough. Let me know if you need more detail. thanks Quote Link to comment https://forums.phpfreaks.com/topic/64975-solved-php-get-image-height-without-the-use-of-input-box/ Share on other sites More sharing options...
php_tom Posted August 15, 2007 Share Posted August 15, 2007 not sure if this would help you: <form action='process.php' method='post'> <input type='hidden' id='hidddenElement1' name='theHeights' /> <input type='submit' value='Submit!' /> </form> <script type='text/javascript'> var str = ""; var images = Array("someImage1","someImage2","someImage3","someImage4","someImage5"); for(i=0;i<4;i++) { str += images[i] + "=" + document.getElementById(images[i]).height + "&"; } str += images[4] + "=" + document.getElementById(images[4]).height; document.getElementById("hiddenElement1").value = str; </script> Then in 'process.php': <?php parse_str($_POST['theHeights']); ?> Obviously the code abouve isn't complete, but is it approximately what you're looking for? Hope it helps. Quote Link to comment https://forums.phpfreaks.com/topic/64975-solved-php-get-image-height-without-the-use-of-input-box/#findComment-324306 Share on other sites More sharing options...
lehula Posted August 15, 2007 Author Share Posted August 15, 2007 YOU ARE AWSOME. THANKS Quote Link to comment https://forums.phpfreaks.com/topic/64975-solved-php-get-image-height-without-the-use-of-input-box/#findComment-324354 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.