Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var idsub = [];
- var namesub = [];
- var matiereID = [];
- var idteacher = [];
- var nameteacher = [];
- var teacherID = [];
- var classNAME = [];
- var count;
- $(function () {
- $("#count").change(function () {
- $('#listsub').empty();
- count = $('#count').val();
- console.log(count);
- getsub();
- });
- });
- function getsub() {
- var Tok = localStorage.getItem("Token")
- $.ajax({
- url: localStorage.getItem("URL") + '/api/subjects',
- type: 'GET',
- dataType: 'json',
- headers: {
- 'Authorization': Tok,
- },
- contentType: 'application/json',
- success: function (data) {
- console.log(data.subjects);
- idsub = [];
- namesub = [];
- $.each(data.subjects, function (key, ob) {
- idsub.push(ob.id);
- namesub.push(ob.name);
- });
- console.log(idsub);
- console.log(namesub);
- console.log(matiereID);
- getteacher();
- },
- error: function (XMLHttpRequest, textStatus, errorThrown) {
- console.log(XMLHttpRequest.responseText);
- console.log(XMLHttpRequest.status);
- },
- });
- }
- function getteacher(){
- var data = [
- {
- "id": "1",
- "name": "prof1"
- },
- {
- "id": "2",
- "name": "prof2"
- },
- {
- "id": "3",
- "name": "prof3"
- }
- ];
- idteacher = [];
- nameteacher = [];
- $.each(data, function (key, ob) {
- idteacher.push(ob.id);
- nameteacher.push(ob.name);
- });
- console.log(idteacher);
- console.log(nameteacher);
- console.log(teacherID);
- listcreate();
- }
- function listcreate(){
- $('#listclass').empty();
- for (var i = 0; i < count; i++) {
- $('#listclass').append('<ul data-role="listview" id="listclass'+ i +'"><li id="li' + i + '">' + '<input type="text" name="Nom de la classe" id="classname' + i + '" placeholder="Nom de la classe ' + i + '">' + '</li><select onchange="selectsub(this, ' + i + ');" name="selectsubjec' + i + '" id="subject' + i + '"><option value="none">matiere</option></select> <select onchange="selectteacher(this, ' + i + ');" name="selectteacher' + i + '" id="teacher' + i + '"><option value="none">prof</option></select>')
- $.each(namesub, function (index, sub) {
- $('#subject' + i).append('<option value="' + index + '">' + sub + '</option>')
- });
- $.each(nameteacher, function (index, sub) {
- $('#teacher' + i).append('<option value="' + index + '">' + sub + '</option>')
- });
- }
- }
- function selectsub(sel, indexsub) {
- matiereID[indexsub] = idsub[sel.value];
- console.log(matiereID);
- }
- function selectteacher(sel, indexsub) {
- teacherID[indexsub] = idteacher[sel.value];
- console.log(teacherID);
- }
- function sendclass(){
- for (var e = 0; e < count; e++) {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement