0

I am developing a slider to set my budget and would like to achieve the value which I set in slider1.php. However, when I tried using the code below, I encountered an error "Notice: Undefined index: slideStatus in C:\xampp\htdocs\1204763e\slider1\slider1.php on line 4 Thank you , says the PHP file"

In slide.php, I inserted this set of code:

     <html>
    <head>
    <script language="JavaScript" type="text/javascript">

    function ajax_post(val){

        var hr = new XMLHttpRequest();

        var url = "slider1.php";
        var ss = document.getElementById('sliderStatus').innerHTML = val;
        var vars = "sliderStatus="+ss;
        hr.open("POST", url, true);

        hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

        hr.onreadystatechange = function() {
            if(hr.readyState == 4 && hr.status == 200) {
                var return_data = hr.responseText;
                document.getElementById("status").innerHTML = return_data;
            }
        }
        // Send the data to PHP now... and wait for response to update the status div
        hr.send(vars); // Actually execute the request
        document.getElementById("status").innerHTML = "processing...";
    }
    </script>
    </head>
    <body>
    <h2>Ajax Post to PHP and Get Return Data</h2>

    <input type="range" name="slide" min="0" max="100" value="50" step="2" onChange="ajax_post(this.value)" />
    <br /><br />
    <span id="sliderStatus">50</span>
    <br/><br/>

    <div id="status"></div>

    </body>
    </html>



In slider1.php, I inserted this set of code:

    <?php 
    echo 'Thank you '. $_GET['slideStatus'] . ', says the PHP file';
    ?>

1 Answer 1

3

You seem to try to access "slideStatus" but you are posting "sliderStatus".

Sign up to request clarification or add additional context in comments.

3 Comments

Do you know at which part of the code must I insert &yen; if I wish to display the yen sign in front of the value?
there : var ss = document.getElementById('sliderStatus').innerHTML = '&yen;'+val
sorry but I still could achieve that result after I add '&yen;'+ before val. Is there any other way?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.