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

The Archive Base Latest Questions

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

My first time with html5, trying to get this jquery ui slider to send

  • 0

My first time with html5, trying to get this jquery ui slider to send the correct value to this html5 canvas opacity. After some googling and messing around, I have it kind of working here: http://jsfiddle.net/y54Es/25/ when you use it, you’ll see what I mean, no image appears until the slider has moved, I know that has to do with the order I have the functions in, I just cant get it to work anyway else, here is my code below:
JS:

    $("#slider").slider({
  animate: true,
  range: "min",
  value: 0.5,
  min: 0,
  max: 0.9,
  step: .01,

  slide: function (event, ui) {
    $('#hiddenField').attr('value', ui.value);
    $("#slider-result").html(ui.value);
    var canvas = document.getElementById("myCanvas");
    var ctx = canvas.getContext("2d");
    var valueVar = $('#hiddenField').val();
    var img1 = loadImage('http://moosepic.com/test2.png', main);
    var img2 = loadImage('http://moosepic.com/test.png', main);

    var imagesLoaded = 0;

    function main() {
      imagesLoaded += 1;

      if (imagesLoaded == 2) {
        // composite now
        ctx.drawImage(img1, 0, 0, 300, 300);
        if (valueVar == 0) {

        } else {
          ctx.globalAlpha = valueVar;
          ctx.drawImage(img2, 0, 0, 300, 300);
        }
      }
    }

    function loadImage(src, onload) {
      var img = new Image();

      img.onload = onload;
      img.src = src;

      return img;
    }
  }

});

Any help on how to make the second image completely cancel out when the slider is all the way to the left would be awesome… and if anyone could help me load the initial image onto the canvas onload, that would be awesome too.

  • 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-17T19:05:08+00:00Added an answer on June 17, 2026 at 7:05 pm

    The slide method you are using is only called when the slider is actually being adjusted. jQueryUI Slider object also provides a create method which is called once when the slider is created on page load.

    I’d suggest using this to perform the initial setup of the canvas. e.g. loading canvas images etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get the initial number value of a string using jQuery/Javascript. Right
I'm having all kinds of grief trying to re-use a jQuery-UI dialog. First time
I'm trying-out qUnit for the first time but can't get any tests to run.
First time working with JSON in Rails and trying to figure out something which
I'm having a hell of a time trying to get (what I thought was)
this is my first time at stack overflow so I'm sorry if the format
I'm a noob at json (know a bit of jquery)....and trying to get a
I am trying to pull data from my XML sheet, this is the first
I'm trying to do a Jquery Ajax search with multiple conditions, and this is
I'm trying to bind some list item links in jquery mobile to a click

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.