Guest User

Untitled

a guest
Jan 18th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. <?=
  2. $form->field($check, 'brightnessLevel')
  3. ->label('Яркость')
  4. ->input('range', [
  5. 'id' => 'brightness',
  6. 'value' => 0,
  7. 'min' => -100,
  8. 'max' => 100
  9. ])
  10. ?>
  11.  
  12. function setDefaultValue() {
  13. var xhmlhr = new XMLHttpRequest();
  14. xhmlhr.withCredentials = true;
  15. xhmlhr.open('GET', '/url/url');
  16. xhmlhr.send();
  17. xhmlhr.onreadystatechange = function() {
  18. if (this.readyState === 4 && this.status === 200)
  19. defalutVal = xhmlhr.responseText;
  20. brightness.setAttribute('disabled', true);
  21. brightness.value = defalutVal;
  22. changeBrightness();
  23. }
  24. }
  25.  
  26. public function actionUpdate($id)
  27. {
  28. $check = new EditingImage();
  29. $model = $this->findModel($id);
  30. if ($check->load(Yii::$app->request->post())) {
  31. // if ($model->save()){
  32. // }
  33. // здесь значение теряется (если не таскать сам ползунок, а именно через js пытаться устанавливать)
  34. $check->status = $check::STATUS_ON;
  35. $check->dir = Images::IMAGES_DIR;
  36. $check->url = $model->url;
  37. if ($check->increaseBrightness())
  38. return $this->redirect(['view', 'id' => $model->id]);
  39. }
  40. return $this->render('update', [
  41. 'model' => $model,
  42. 'check' => $check,
  43. ]);
  44. }
  45.  
  46. console.log('defalutVal: ' + defalutVal);
  47. console.log('brightnessVal: ' + brightness.value);
  48. brightness.value = defalutVal;
  49. console.log('brightness.value = defalutVal (' + brightness.value + ')');
  50.  
  51. brightness.setAttribute('disabled', true);
Add Comment
Please, Sign In to add comment