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 9132353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:17:54+00:00 2026-06-17T08:17:54+00:00

I am using jCrop and I need a set aspect ratio. For example, if

  • 0

I am using jCrop and I need a set aspect ratio. For example, if someone enters “2” to X textbox and “2” to Y textbox, the aspect ratio should be 1.

However, if I change the values on textboxes (e.g to 3 and 1), jCrop should obtain the new values. Right now it only initializes, and doesn’t look back.

The code is the following. (I tried alot more but couldn’t figure it out.)

-JQUERY-
jQuery(function($){
   var numberX = $('#numberX').val();
   var numberY = $('#numberY').val();

   $('#jcrop_target').Jcrop({
      aspectRatio: ($(this).numberX / $(this).numberY),
   ... rest of the codes

-HTML-
<input type="text" id="numberX" name="numberX" value=""/>
<input type="text" id="numberY" name="numberY" value="" />

TLDR; When I change values of numberX and numberY textboxes, it should reflect to jCrop. jCrop only keeps the init values. When values on textboxes change, aspect ratio should be re-calculated.

Any help would be greatly appreciated!

  • 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-17T08:17:54+00:00Added an answer on June 17, 2026 at 8:17 am

    Make your code into a function(). Then with jQuery you can run the function on document.ready and on change (See http://api.jquery.com/change/)

    For example,

    function changenumbers(){
       var numberX = $('#numberX').val();
       var numberY = $('#numberY').val();
    
       $('#jcrop_target').Jcrop({
          aspectRatio: ($(this).numberX / $(this).numberY),
       /* ... rest of the code */
    }
    $document.ready(function(){
       changenumbers();
       $("#numberX").change(function(){ changenumbers(); }
       $("#numberY").change(function(){ changenumbers(); }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using jcrop to crop my photos and need to send the current values
I am using jcrop to crop the image in my php application.I am using
I am using jcrop to implement image cropping in my site. After clicking on
I want to crop an image at the server side (I am using 'JCrop'
I'm at a loss. I'm using JQuery 1.4.2 and JCrop 0.98. Everything else works
Using InteliJ IDEA , I am trying to set up multiple projects to run
I am using Jcrop jQuery to crop an image in an MVC3 application. The
I'm adding an image to the page and then using JCrop on it, but
I am trying to crop the image using JQuery Jcrop plugin with Java Stuff,
I need help with my jcrop preview. I am following this tutorial from railscasts

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.