Buy Licenses Contact Support Login/Register
v 1.7.9
v 1.7.9
Overview Examples Docs Source Download

Barrating

Custom widget: Bar rating widget

Third-party libraries: Barrating MIT

                        
        
            Survey.StylesManager.applyTheme("default");
        


            
                var json = {
  "elements": [
    {
      "type": "barrating",
      "name": "barrating1",
      "ratingTheme": "fontawesome-stars",
      "title": "Please rate the movie you've just watched",
      "choices": [ "1", "2", "3", "4", "5" ]
    }
  ]
};

                window.survey = new Survey.Model(json);
            
        
            survey.onComplete.add(function(result) {
            document.querySelector('#surveyResult').textContent =
            "Result JSON:\n" + JSON.stringify(result.data, null, 3);
            });
        
        
            $("#surveyElement").Survey({
            model: survey 
            });
        

                    
<!DOCTYPE html>
<html lang="en">
<head>
    <title>Custom widget: Bar rating widget, jQuery Survey Library Example</title>

<meta name="viewport" content="width=device-width" />
    <script src="https://unpkg.com/jquery"></script>
<script src="https://surveyjs.azureedge.net/1.7.9/survey.jquery.js"></script>
<link href="https://surveyjs.azureedge.net/1.7.9/survey.css" type="text/css" rel="stylesheet" />
    <link rel="stylesheet" href="./index.css">
<script src="https://unpkg.com/jquery-bar-rating"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css">
<!-- Themes -->
<link rel="stylesheet" href="https://unpkg.com/jquery-bar-rating@1.2.2/dist/themes/bars-1to10.css">
<link rel="stylesheet" href="https://unpkg.com/jquery-bar-rating@1.2.2/dist/themes/bars-movie.css">
<link rel="stylesheet" href="https://unpkg.com/jquery-bar-rating@1.2.2/dist/themes/bars-pill.css">
<link rel="stylesheet" href="https://unpkg.com/jquery-bar-rating@1.2.2/dist/themes/bars-reversed.css">
<link rel="stylesheet" href="https://unpkg.com/jquery-bar-rating@1.2.2/dist/themes/bars-horizontal.css">
<link rel="stylesheet" href="https://unpkg.com/jquery-bar-rating@1.2.2/dist/themes/fontawesome-stars.css">
<link rel="stylesheet" href="https://unpkg.com/jquery-bar-rating@1.2.2/dist/themes/css-stars.css">
<link rel="stylesheet" href="https://unpkg.com/jquery-bar-rating@1.2.2/dist/themes/fontawesome-stars-o.css">
    <script src="https://surveyjs.azureedge.net/1.7.9/surveyjs-widgets.js"></script>

</head>
<body>
    
            <div id="surveyElement" style="display:inline-block;width:100%;">
            </div>
    <div id="surveyResult"></div>

<script type="text/javascript" src="./index.js"></script>

</body>
</html>
settings

Bar rating theme: (default is 'fontawesome-stars')

var q = survey.getQuestionByName('barrating1');
q.ratingTheme = yourvalue; 
survey.render();

var q = survey.getQuestionByName('barrating1');
q.showValues = yourvalue; 
survey.render();