Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am displaying the CSV data in a paginated format. Based on the number of columns in my CSV file, I have those many sliders to choose the range. The code to display the initial CSV file and the dynamic generation of sliders based on the number of CSV columns is as below.

<!DOCTYPE html>
<html>
<div id = "myDiv"> 
<!-- Include jQuery -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="js/simple-slider.js"></script>
<?php include 'index.php'; ?>
<?php 
      $totalcolumns = $_SESSION["totalcolumns"];
?>

<!-- Include Simple Slider JavaScript and CSS -->
<link href="css/simple-slider.css" rel="stylesheet" type="text/css" />
<link href="css/simple-slider-volume.css" rel="stylesheet" type="text/css" /> 
<script src="css/simple-slider.js"></script>
<link href="css/simple-slider.css" rel="stylesheet" type="text/css" />

<!-- Activate Simple Slider on your input -->
  <h2>Keyword Scores</h2>
  <?php

$i = 1;
while (++$i <= $_SESSION['totalcolumns']) {
    $range = $_SESSION["min-column-$i"] . ',' . $_SESSION["max-column-$i"];?>
        <br><?php echo "Keyword" ?>
        <?php echo $i -1 ?>
        <br><input type="text" data-slider="true" data-slider-range="<?php echo $range ?>" data-slider-step="1">
        <?php } ?>

        <button type="button" >Update</button>



<script>

    var masterdata;      
    $("[data-slider]")

       .each(function () {
           var range;
            var input = $(this);
            $("<span>").addClass("output")
                .insertAfter(input);
            range = input.data("slider-range").split(",");
            $("<span>").addClass("range")
                .html(range[0])
                .insertBefore(input);
            $("<span>").addClass("range")
                .html(range[1])
                .insertAfter(input);
        })
        .bind("slider:ready slider:changed", function (event, data) {
            $(this).nextAll(".output:first")
                .html(data.value.toFixed(2));
                 masterdata = data.value;

        });


</script>

<script>

function loadXMLDoc()
        {
        $.ajax({
                    type: "POST",
                    url: "update.php",
                    data: { value : masterdata },
                    success: function(data)
                    {
                        alert(data);
                    }
                }); 

}
$("button").on('click',function(){ loadXMLDoc(); });
</script>
</div>
</html>

The working example of the above code is here. However, after selecting the slider ranges, I need to display only those values matching the criteria. For this I am using the ajax to pass it to another PHP file. However, I am able to pass only one variable rather than the array of values. I am very new to the web development and have no idea of ajax or json encoding. Can someone give me an idea of what should I do next so that I can update the display of my CSV file?

share|improve this question
 
What do you call a slider? I don't see any JavaScript on the page you link to. –  Sébastien Oct 12 '13 at 20:02
 
I am sorry. This is the correct link. –  ram esh Oct 12 '13 at 20:04
 
You have a lot of problems already in your HTML: you have 2 closing html tags and a lot of HTML/JavaScript in a no man's land after body. Also your inputs are not in a form. Putting them in a form would make it much easier to work with them via jQuery. Basically you have to start smaller and take it one step at a time. –  Sébastien Oct 12 '13 at 20:11
 
Do you know like what all changes need to be done? Can you please let me know the steps that needs to be taken? I am very new to all these technologies and am just trying to figure out everything just by googling. So only my code looks shabby and I have very limited knowledge on how to proceed further. Thanks! –  ram esh Oct 12 '13 at 20:14
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.