Skip to main content
RenoToonen
Inspiring
December 6, 2018
Answered

Changing the position of an object @ a certain ComboBox value (HTML5 canvas)

  • December 6, 2018
  • 1 reply
  • 182 views

Hi all:),

I'm trying to change the position of objectX to a certain coordinate after the user is using a ComboBox value. To do this I'm using the following code. The ComboBox is basically a dropdown with values from 1-10. Ive tried both if (value == 2)  and if (value == "2"), but this just does not seem to work. Anyone knows how to do this?

Thanks very much in advance!

The code:

var _this = this;

$('#dom_overlay_container').on('change', '#Touchpoint1_Dropdown', function() {

     var value = $('#Touchpoint1_Dropdown').val();

     if (value == 2) {

          this.objectX.x = 200;

          this.objectX.y = 100;

     }

}.bind(_this));

This topic has been closed for replies.
Correct answer RenoToonen

Apparently I used the wrong command to get the value of the ComboBox. Right now I succeeded by using

$('#dom_overlay_container').on('change', '#Touchpoint1_Dropdown', function () {

if (Touchpoint1_Dropdown.selectedIndex == 0) {

this.objectX.x = 200;

this.objectX.y = 700;

}

1 reply

RenoToonen
RenoToonenAuthorCorrect answer
Inspiring
December 7, 2018

Apparently I used the wrong command to get the value of the ComboBox. Right now I succeeded by using

$('#dom_overlay_container').on('change', '#Touchpoint1_Dropdown', function () {

if (Touchpoint1_Dropdown.selectedIndex == 0) {

this.objectX.x = 200;

this.objectX.y = 700;

}