-1

How can I set dynamic values for function onKeyUp? Right now I'm hardcoding the number but I need to retrieve it from a php variable.

php value

$num = $queryResults['col_number'];

html

<input onKeyUp="if(this.value>'$num'){this.value='$num';}
else if(this.value<0){this.value='0';}" />
Balloon Fight
  • 661
  • 8
  • 16

1 Answers1

1

You need to output the value using <?php echo $num ?> or shorter <?= $num ?>

<input onKeyUp="if(this.value>'<?= $num ?>'){this.value='<?= $num ?>';} else if(this.value<0){this.value='0';}" />
Mikey
  • 6,728
  • 4
  • 22
  • 45