Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8089705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:29:16+00:00 2026-06-05T19:29:16+00:00

I have created a reiszable box using jQuery UI and I then pass the

  • 0

I have created a reiszable box using jQuery UI and I then pass the values to a text box. The values can be in either CM or Inches.

The problem I have is when you drag the size after selecting Centimeters from the unit_type box, It reverts back to Inches. I think I just need to rethink the logic on it and remap it all out.

Can anyone help on this..?

Code is…

$(function()
{
    $("#resizable").resizable({
        aspectRatio: 16 / 9,
        maxWidth:  $("#max_width").val(),
        maxHeight: $("#max_height").val(),
        resize: function() {

            var widthInch = $("#resizable").width() / 200;
            var heightInch = $("#resizable").height() / 200;

            $("#unit_type").change(function()
            {
                var widthCM = $("#resizable").width() / 200 * 2.54;
                var heightCM = $("#resizable").height() / 200 * 2.54;

                $(".width").val(widthCM + '' + ' CM');
                $(".height").val(heightCM + '' + ' CM');
            })

            var widthCM = $("#resziable").width() / 200 * 2.54;
            var heightCM = $("#resizable").height() / 200 * 2.54;

            $(".width").val(widthInch + '' + ' Inches');
            $(".height").val(heightInch + '' + ' Inches');
        }
    });
})

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T19:29:18+00:00Added an answer on June 5, 2026 at 7:29 pm

    The problem lies in where you are calculating the size. The best solution is to pull this out into a new function and then call that function when the box is resized or the unit is changed. Something like this should work. (You’ll have probably modify it to fit your exact markup as I made some assumptions.)

    $(function()
    {
        $("#resizable").resizable({
            aspectRatio: 16 / 9,
            maxWidth:  $("#max_width").val(),
            maxHeight: $("#max_height").val(),
            resize: updateSize
        });
    })
    
    $("#unit_type").change(updateSize);
    
    function updateSize() {
       unit = $("#unit_type").val();
       if(unit == "in") {
                var widthInch = $("#resizable").width() / 200;
                var heightInch = $("#resizable").height() / 200;
    
                $(".width").val(widthInch + '' + ' Inches');
                $(".height").val(heightInch + '' + ' Inches');
       } else if(unit == "cm") {
                var widthCM = $("#resizable").width() / 200 * 2.54;
                var heightCM = $("#resizable").height() / 200 * 2.54;
    
                $(".width").val(widthCM + '' + ' CM');
                $(".height").val(heightCM + '' + ' CM');
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using jquery dialog I have created a popup box with a form. I am
alt text http://img705.yfrog.com/img705/1337/layoutxt.jpg I already have this layout created using CSS, but its plagued
I have created a basic site using ASP.NET routing according to Mike Ormond's example
I have created a file with XmlDocument xmldoc = new XmlDocument(); Can I make
I have created one table using the below command: create table Table1( Id int
I am using MVC3 and added model validation with required attributes. Then I have
I have a really annoying issue with jQuery and/or the jQuery UI Dialog Box.
I have created application using TSQL and libraries. Right now I am generating clients
I just don't know how to explain my problem. So I have created an
I am using JQuery and Jquery UI to create a dialog box which contains

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.