Pulling Javascript variable value into SQL variable

(3 posts) (2 voices)
  1. wattsm, Member

    Hi,

    I have a simple html slider whose value I need to pull into a SQL variable, is there a way that I can pass the value from the variable from the javascript into my SQL variable?

    The below does not work:

    SELECT 'dbr.html','<input type="range" min="0" max="10" value="5" step="1" onchange="showValue(this.value)" /> <span id="range">5</span> <script type="text/javascript"> function showValue(newValue) { document.getElementById("range").innerHTML=newValue; } </script>' ;

    SET sliderres = this.value; SELECT sliderres;

    I then want to use the values from these sliders as inputs into a procedure called from a button, so I need to have the JS variable information stored in the SQL variable at the point of the button click.

    Thanks,
    Martin

  2. myDBR Team, Key Master

    Martin,
    if you attach a myDBR report link to a button, myDBR creates an anchor element (<a) where the URL is in the href-attribute. You can pass the range value into the URL by replacing the corresponding parameter in the URL in your showValue-function.

    There are couple of steps you need to do:

    - Create the button with URL and pass an editable parameter value '<=' to it to create a placeholder
    - Change the editable parameter value to direct value, so the value is not asked again from the user when button is clicked
    - Pass the changed value to the URL when input range value changes

    See example.

    --
    myDBR Team

  3. wattsm, Member

    Thanks for the quick response guys, the described steps work and I've been able to generalise it to my report.

    Thanks,
    Martin


Reply

You must log in to post.