0

I was trying to do like a small function to calculate a re-size value of an image:

index.php

<?php
list($width, $height, $type, $attr) = getimagesize("image.jpeg"); 
echo '<form id="dimensions" action=''>';                                              
echo '<input type="text" class="input1" id="width" value="' . $width . '" onchange="widthfunc()"/>';      
echo '<input type="text" class="input1" id="height" value="' . $height . '" onchange="heightfunc()"/>';          
echo '<input type="text" class="input1" id="resize" value="' . $resize . '%" onchange="resizefunc()"/>'; 
echo '<input type="submit" value="change" name="change"/>';
echo '</form>';   
?>

site.js

function widthfunc()
{
    var x=document.dimensions.getElementById("height");  
    var y=document.dimensions.getElementById("width");
    var z=document.dimensions.getElementById("resize");
    var a = 1280;
    var b = 1024;
    var c = 100;

    x.value=y.value * b / a;
    z.value=(a*b)/(x.value*y.value);

}
function heightfunc()
{
    var x=document.dimensions.getElementById("height");  
    var y=document.dimensions.getElementById("width");
    var z=document.dimensions.getElementById("resize");
    var a = 1280;
    var b = 1024;
    var c = 100;

    x.value=y * b / a;
    z.value=(a*b)/(x*y);

}
function resizefunc()
{
    var x=document.dimensions.getElementById("height");  
    var y=document.dimensions.getElementById("width");
    var z=document.dimensions.getElementById("resize");
    var a = 1280;
    var b = 1024;
    var c = 100;

    x.value=y * b / a;
    z.value=(a*b)/(x*y);

}

Well, by default the value should be the original value of an image, unless, the user changes one of the fiels width height or size (in %), I would like that the javascript would change the other 2 values ...

1
  • Please explain it more.. Do u want to change the values of resize input box on change of height and width? Commented May 9, 2013 at 10:21

1 Answer 1

1

JavaScript can not change PHP, you can send requests via AJAX but JavaScript is client side while PHP is server side, apples and oranges mate.

if you're trying to store the previous and resized value just use 2D arrays and store your data in there, or 2 normal arrays whatever you prefer.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.