Fetch data from mysql by checking radio button - php

i have few models of products and when i click on each model to show me his variants, like on image from below
Here is what i made in html :
<div class="owl-carousel owl-theme no-pb slide-arrow-2" data-
dots="false" data-nav="true" data-items="4" data-lg-items="3"
data-md-items="2" data-sm-items="2" data-margin="30" data-
autoplay="false">
<?php
$qua = "SELECT * FROM produse WHERE categorie = '$id' ORDER BY pozitie";
$qla = mysqli_query($conn, $qua);
while($rova = mysqli_fetch_assoc($qla)){?>
<?php
$id_paletar = $rova['id'];
$sql2=mysqli_query($conn,"SELECT * FROM pret_produse WHERE produs_id='$id_paletar'");
$pret2=mysqli_fetch_array($sql2);
?>
<div class="item">
<div class="product-item">
<div class="product-img">
<img class="img-fluid" src="cms/produse/<?=$rova['poza'];?>" alt="">
<div class="product-overlay">
<ul class="list-unstyled">
</ul>
</div>
</div>
<div class="product-btn ifix">
<div class="btn btn-theme btn-block btn-new" ><span style="font-size: 15px;"><?=$rova['titlu'];?></span>
<div>
<label class="containere">
<input type="radio" name="produse" id="paletar_pret" class="palt" value="<?=$rova['id'];?>">
<p class="checkmark"></span>
</label>
</div>
</div>
</div>
</div>
</div>
<?php }?>
</div>
Here is my jquery:
$(document).ready(function(){
$('.palt').change(function() {
if(this.checked) {
var check= $(this).val();
alert(check);
$.ajax({
url: 'cere_cotatie.php',
type: 'POST',
data: {check:check},
success: function(data){
$('.fetch').append(data);
}
});
}
});
And here is my php file which i use on ajax to call:
<?php
if($_POST)
{
include('config.php');
echo $check = $_POST['check'];
$s = "SELECT * FROM variante WHERE id_var='$check'";
$q = mysqli_query($conn, $s);
while ($r = mysqli_fetch_assoc($q)) {?>
<div class="item" style="width:220px;">
<div class="product-item">
<div class="product-img">
<img class="img-fluid" src="cms/variante/<?=$r['poza'];?>" alt="">
<div class="product-overlay">
<ul class="list-unstyled">
</ul>
</div>
</div>
<div class="product-btn ifix">
<div class="btn btn-theme btn-block btn-new" ><span style="font-size: 15px;"> <?=$r['denumire'];?></span>
<div>
<label class="containere">
<input type="checkbox">
<p class="checkmark"></span>
</label>
</div>
</div>
</div>
</div>
</div>
<?php }?>
<?php }
?>
My problem is like this if i check first box to display me variants of what i checked but my code is doing this way, if i check first box is loading data and after that if i check another box results from first box need to dissapear and to be only what i check.
EDIT: in that print screen you can see the problem.

I think you should add below code
$('.palt').change(function(e) {
e.preventDefault();
});
and remove alert(check);
Hope it work for you.

Related

Codeigniter Ajax: E-commerce The Query already working but the displaying the data is the problem

I'm making an e-commerce capstone project. The query is already okay but the problem is with displaying the data. If I choose a different category the current category will be hidden and only the new category will be displayed.
https://imgur.com/a/YsLj9S2
<section>
<div class="container">
<div class="row justify-content-center">
<div class="col-sm-9" style="border:solid 1px;">
<div class="row">
<div class="col-sm-4" id="test3">
<div class="card" id="test">
<div class="card-body" id="test2">
<div class="product-grid">
<div class="product-image">
<a href="#" class="image" style="background-color:#F3F3F3;">
<img class="pic-1" src="https://media.comicbook.com/2020/05/dragon-ball-super-when-will-should-goku-master-ultra-instinct-1219439.jpeg?auto=webp&width=1200&height=628&crop=1200:628,smart" class="d-block w-100" id>
</a>
<a class="add-to-cart" id="cart" href=""> + </a>
</div>
<div class="product-content">
<h3 class="title" id="productname">Product Name</h3>
<div class="price" id="price"></div>
</div>
<div class="action-buttons">
<button class="btn btn-danger mt-3" id="cart" onclick="addtocart()"><i class="fas fa-shopping-cart"></i> Add to Cart</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
function searchcategory(category_id) {
$.ajax({
url: "<?php echo base_url() ?>admin/getproducts/" + category_id,
type: "POST",
dataType: "json",
success: function(data) {
$.each(data, function(key, value) {
let row = `<div class="price" id="price">${value.price}</div>`;
let val = `<h3 class="title" id="productname">${value.product_name}</h3> `;
let test = `<button class="btn btn-danger mt-3" id="cart" onclick="${value.product_id}" ><i class="fas fa-shopping-cart"></i> Add to Cart</button>`;
$('#price').append(row);
$('#price').append();
$('#productname').append(val);
/* $('#test3').append(val);
$('#cart').text(test); */
console.log(test);
});
}
});
}

Codeigniter Jquery. How to display data into cards using loop for e-commerce

Help i want to display all of this data in cards. the code already can get the result from model to only problem is to display. my plans is when i click the burgers category it will display all the data in card-body and when i press beverages it will display all the beverages without refreshing. for some reason i need to use jquery.. IMAGE LINK: https://imgur.com/a/2DsBKqG
View:
<div class="col-sm-9" style="border:solid 1px;">
<div class="row">
<div class="col-sm-4">
<div class="card">
<div class="card-body">
<div class="product-grid">
<div class="product-image">
<a href="#" class="image" style="background-color:#F3F3F3;">
<img class="pic-1" src="https://media.comicbook.com/2020/05/dragon-ball-super-when-will-
should-goku-master-ultra-instinct-1219439.jpeg?
auto=webp&width=1200&height=628&crop=1200:628,smart" class="d-block w-100">
</a>
<a class="add-to-cart" href=""> + </a>
</div>
<div class="product-content">
<h3 class="title">Product Name</h3>
<div class="price"></div>
</div>
<div class="action-buttons">
<a class="btn-outline">ADD TO CART</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Jquery:
function searchcategory(category_id)
{
$.ajax(
{
url:"<?php echo base_url() ?>admin/getproducts/"+category_id,
type:"POST",
dataType:"json",
success:function(data)
{
data.forEach(key =>
{
let row = `<div class="price" id="price" >${key.price}</div>`;
});
}
});
}

Bootstrap Cards Filter PHP/AJAX Problems

I have a page of a website which has bootstrap cards on. The cards are generated dynamically, but I wanted to add a filter section. I am trying to use AJAX to acheive this, I have got to a point where when you select a checkbox it triggers the loader gif but then that loader gif doesn't disapear. Through my hours of debugging I can see that its the page that the AJAX call is calling that is the problem, but I just can't see what the issue is and I am not getting errors or anything in the console.
If anyone has any ideas I would really appreciate it, I have pasted my code below, also I am aware my sql queries are currently open to injection, just want to get it to work first.
<body>
<?php include("PHP/header.php"); ?>
<div class="container-fluid">
<div class="container" style="margin-top: 2%; text-align: center;">
<h1>Title goes here</h1>
Some tetx
<br/>
<br/>
<br/>
Filter Reviews:
<ul class="list-group">
<?php
$search = $conn->prepare("SELECT DISTINCT reviewcat FROM review_db ORDER BY reviewcat");
$search->execute();
while ($row = $search->fetch(PDO::FETCH_ASSOC)) {
?>
<li class="list-group-item">
<div class="form-check">
<label class="form-check-label">
<input type="checkbox" class="form-check-input product_check" value="<?=$row['reviewcat'];?>" id="reviewcat"> <?=$row['reviewcat']; ?>
</label>
</div>
</li>
<?php } ?>
</ul>
</div>
<br/><br/>
<div class="row-fluid ">
<h5 class="text-center" id="textChange"> All Products </h5>
<hr>
<div class="text-center">
<img src="Images/loader.gif" id="loader" width="100" style="display: none">
</div>
<div id="result" class="card-deck card_group_style pt-4" >
<?php
$res_data = $conn->prepare("SELECT * FROM review_db");
$res_data->execute();
?>
<?php while ($row = $res_data->fetch(PDO::FETCH_ASSOC)) {// Important line !!! Check summary get row on array .. ?>
<div class="col-sm-6 col-lg-3 py-2">
<div class="card mb-4">
<img class="card-img-top card-images " src="Images/Reviews/<?php echo $row['reviewimage1'];?>" alt="<?php echo $row['reviewtitle'];?>" >
<div class="card-body">
<h5 class="card-title"><?php echo $row['reviewtitle'];?></h5>
<p class="card-text"><?php echo $row['reviewsynop'];?></p>
<a href="Reviews/review-content.php?id=<?php echo $row['id'];?>&reviewtitle=<?php echo $row['reviewtitle'];?>" class="btn btn-primary my-4" >Read More</a>
<div class="card-footer" style="padding: 1%;">
<small class="text-muted">Submitted: <?php
$my_date = $row['reviewsub'];
$date = DATE("d/m/Y",strtotime($my_date));
echo $date;?></small>
</div>
</div>
</div>
</div>
<?php } ?>
</div>
</div>
</div>
<?php include("PHP/footer.php"); ?>
</div>
</body>
<?php include("PHP/js.php"); ?>
<script>
$(document).ready(function(){
$('#link-review,#link-footer-review').addClass('active');
});
</script>
<script type="text/javascript">
$(document).ready(function(){
function get_filter_text(text_id){
var filterData = [];
$('#'+text_id+':checked').each(function(){
filterData.push($(this).val());
});
return filterData;
}
$(".product_check").click(function(){
$("#loader").show();
var action = 'data';
var reviewcat = get_filter_text('reviewcat');
$.ajax({
method:'POST',
url:'reviewaction.php',
data:{action:action,reviewcat:reviewcat},
success:function(response){
$("#result").html(response);
$("#loader").hide();
$("#textChange").text("Filtered Reviews");
}
});
});
});
</script>
</html>
reviewaction.php
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
include_once $_SERVER['DOCUMENT_ROOT'] . '/Private/db.php';
// $stmt = $conn->prepare("SELECT * FROM blogdata ORDER BY blogsub DESC");
// $stmt->execute();
?>
<?php
if(isset($_POST['action'])){
$sql = "SELECT * FROM review_db WHERE reviewcat !=''";
$revsearch = $conn->prepare($sql);
$revsearch->execute();
$output='';
if($revsearch->num_rows>0){
while ($row = $revsearch->fetch(PDO::FETCH_ASSOC)) {
$output .= '
<div class="col-sm-6 col-lg-3 py-2">
<div class="card mb-4">
<img class="card-img-top card-images " src="Images/Reviews/'. echo $row['reviewimage1'];.'" alt="'. echo $row['reviewtitle'];.'" >
<div class="card-body">
<h5 class="card-title">'. echo $row['reviewtitle'];.'</h5>
<p class="card-text">'. echo $row['reviewsynop'];.'</p>
<a href="Reviews/review-content.php?id='. echo $row['id'];.'&reviewtitle='. echo $row['reviewtitle'];.'" class="btn btn-primary my-4" >Read More</a>
<div class="card-footer" style="padding: 1%;">
<small class="text-muted">Submitted: '.
$my_date = $row['reviewsub'];
$date = DATE("d/m/Y",strtotime($my_date));
echo $date;.'</small>
</div>
</div>
</div>
</div>
';
}
else{
$output = "<h3>No Reviews Found!</h3>";
}
echo $output;
}
?>
I have actually found something in the server error log, I was stupidly only use dev tools on firefox, but have found that in the reviewaction.php script I had left semicolons in and had also missed a closing bracket. There are still some other problems, which I can fix, just couldn't work out why it wasn't firing.

How to post AJAX response to all logged in users as an update

I currently have this code that post for only one user and i want to know if it's possible, that the ajax response can be posted as an update to all logged in users as an update on the website. I appreciate all efforts.
<form method="post" action="" id="postForm">
<input type="hidden" name="userId" id="userId" value="<?php echo $_SESSION['USERID']; ?>" />
<select name="type" class="form-control" style="border:1px solid #eee; border-radius:5px; width:auto !important;">
<option value="">select type of post</option>
<option value="default">Normal Post</option>
<option value="Testimonies">Testimonies</option>
<option value="Prayer">Prayer Request</option>
<option value="counselling">Counselling</option>
<option value="Dreams">Dreams Interpretation</option>
</select>
<textarea class="form-control" style="border:none; resize:none;" rows="1" name="post" id="post" placeholder="What's God saying through you today? <?php $text = explode(' ', $_SESSION['NAME']); echo $text[0]; ?>"></textarea>
<button type="submit" value="postForm" class="submitIt btn btn-info btn-flat">Post</button>
</form>
The AJAX Part
<script>
$(document).ready(function(){
$( "body" ).delegate( ".submitIt", "click", function(e) {
e.preventDefault();
e.stopPropagation();
//the button value
$url = "http://localhost/christ/ajaxPages/";
var buttonValue = $(this).val();
//alert(buttonValue);
if(buttonValue == "postForm") {
var formdata = $('#postForm').serialize();
//alert(formdata);
$.ajax({
type: "POST",
url: $url + "addit.php",
data: formdata,
success: function(data){
$("#discuss").append(data);
$("#post").each(function(){autosize.destroy(this);});
$("#post").val("");
}
})
});
</script>
This is the addit.php file called by above ajax
<?php
include '.././config.php';
//waste in dispose
$arr[] =0;
$db_con = connect();
$sect = $_POST['post'];
$type = $_POST['type'];
$userId = $_POST['userId'];
$date = date('Y-m-d H:i:s');
//time of psoidting
$time = strtotime($date);
$sql = "insert into post(post_body,userId,post_type,date) values(:data,:userId,:type,:dateposted)";
$bio = $db_con->prepare($sql);
$bio->bindParam('data', $sect);
$bio->bindParam('type', $type);
$bio->bindParam('userId', $userId);
$bio->bindParam('dateposted', $date);
$bio->execute();
$arr = $bio->errorInfo();
if($arr[2] == "") {
$disc = $db_con->prepare("select * from post where post_body = :text and userId = :userId");
$disc->bindParam("text", $sect);
$disc->bindParam('userId', $userId);
$disc->execute();
$row = $disc->fetch();
$_SESSION['postId'] = $row['post_id'];
//let us retrive
echo '<!-- Box Comment -->
<div class="box box-widget" id="lofty-'.$row['post_id'].'">
<div class="box-header with-border" style="border-radius:5px 5px 0 0;">
<div class="user-block">
<img class="img-circle" src="'.$url.'/'.userName('icon', $_SESSION['USERID']).'" alt="User Image">
<span class="username"><a style="color:#1da1f2;" href="#">'.ucfirst($_SESSION['NAME']).'</a></span>
<span class="description">Shared - ';
echo humanTiming($time);
echo '</span>
</div>
<!-- /.user-block -->
<div class="box-tools">';
if($row['userId'] == $_SESSION['USERID']) {
echo '<div class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><span style="color:#fff">Dropdown Example</span>
<span class="caret"></span></a>
<ul class="dropdown-menu shadow">
<li><a href="#"><button type="button" data-toggle="modal" data-target="#editModal" class="btn btn-box-tool edit" id="edit-post-'.$row['post_id'].'"><i class="fa fa-edit"></i> Edit</button></li>
<li><button type="button" class="btn btn-box-tool submitIt" value="delete" name="del-'.$row['post_id'].'-'.$_SESSION['USERID'].'-post"><i class="fa fa-trash-o"></i> Delete</button></li>
</ul>
</div>';
}
echo '</div>
<!-- /.box-tools -->
</div>
<!-- /.box-header -->
<div class="box-body">
<p style="white-space:pre-wrap";><span id="replace-'.$row['post_id'].'">'.$sect.'</span></p>
<div style="margin-left:-10px; margin-right:-10px; padding:4px 4px 0 4px;">
<div class="col-lg-6" style="text-align:left">
<span class="text-muted">
<button style="background:none; border:none;" class="btn btn-box-tool BigLike" name="like-'.$row['post_id'].'-'.$_SESSION['USERID'].'">
<i class="fa fa-thumbs-o-up"></i> <span id="change'.$row['post_id'].'"></span></button>
<span id="seeIt'.$row['post_id'].'"></span><span id="seeItbefore'.$row['post_id'].'"></span></span>
</div>
<div class="col-lg-6" style="text-align:right">
<span class="text-muted">
<span id="seeIt2'.$row['post_id'].'"></span><span id="seeItbefore2'.$row['post_id'].'"></span>
</div>
</div>
</div>
<!-- /.box-body -->
<div class="box-footer box-comments" style="background:none; margin:0;" id="comment'.$row['post_id'].'"></div>
<!-- /.box-footer -->
<div class="box-footer" style="border:none; padding-top:1px;">
<form action="." method="post">
<img class="img-responsive img-circle img-sm" src="'.$url.'/'.userName('icon', $_SESSION['USERID']).'" alt="user image">
<!-- .img-push is used to add margin to elements next to floating images -->
<div class="img-push">
<textarea type="text" style="border-radius:20px; background:#eee; border:none; resize:none; overflow:hidden" rows="1" class="form-control input-sm comment-'.$_SESSION['USERID'].'" name="comment-'.'3-'.$row['post_id'].'-'.$_SESSION['USERID'].'" placeholder="Press enter to post comment"></textarea>
</div>
</form>
</div>
<!-- /.box-footer -->
</div>
<!-- /.box-widget -->
<!-- /.box -->';
} else {
echo 'Failed';
}
?>
I want to know if it's possible to modify this code to post the ajax response to all logged in users on the website rather than just the user that made the post. Forgive my English

Using AJAX for passing form inputs in CodeIgniter

I'm a newbie in CodeIgniter and I'm trying to pass my form inputs from the view to the controller. I was able to pass it, and was able to insert it on the database. However, I want to use Ajax for this so the whole page won't reload when I press the submit button. I have watched and tried this youtube tutorial: https://www.youtube.com/watch?v=IURutxKvukA, but it doesn't work for me. :( Thank you in advance!
This is my controller, Teacher.php
public function insert_quiz($quiztitle, $quizdescription, $value="")
{
$data = $this->input->post();
$numData = count($data);
$response = array();
$stringChoices = "";
if($numData > 1)
{
for ($i=4; $i < $numData; $i++)
{
$num = $i-3;
$offset = "inputChoice$num";
if ($i == 4)
{
$stringChoices = $data[$offset];
}
else if ($i != 4)
{
$stringChoices = $stringChoices . "," . $data[$offset];
}
}
}
$quizitems = array('Question' => $data['inputQuestion'], 'Choices' => $stringChoices, 'Correct' => $data['correctanswer'], 'NumSequence' => $data['questionnumber']);
$quizitemid = $this->Teacher_model->insertQuizItemOnQuizItems($quizitems);
if (count($quizitemid) == 1)
{
$quizdeedid = $this->Teacher_model->getQuizDeedId($quiztitle);
$quizdatasetitem = array('QuizSet' => $data['quizsetnumber'], 'QuizItemID' => $quizitemid, 'QuizDeedID' => $quizdeedid);
$quizdatasetid = $this->Teacher_model->insertQuizOnQuizDataSet($quizdatasetitem);
if(count($quizdatasetid) == 1)
{
$response = array(
'status' => "success"
);
echo json_encode($response);
}
}
}
and this is my quiz form, in quizView.php
<div class="container-fluid container-cards-pf container-pf-nav-pf-vertical
nav-pf-persistent-secondary">
<div class="row row-cards-pf">
<!-- Important: if you need to nest additional .row within a .row.row-cards-pf, do *not* use .row-cards-pf on the nested .row -->
<div class="col-xs-12 col-sm-12 col-md-12">
<div class="card-pf">
<div class="card-pf-heading">
<h1 align="center">
<strong><?php echo str_replace("%20", " ", $quizTitle); ?></strong>
</h1>
<h2 class="card-pf-title" align="center">
<label><?php echo str_replace("%20", " ", $quizDescription); ?></label>
</h2>
</div>
<div class="card-pf-body" id="divquizset" style="height: 50px">
<div class="col-sm-2">
</div>
<div class="col-sm-9" id="divquizset">
<div class="col-sm-3">
<p align="right"> QUIZ SET: </p>
</div>
<div class="col-sm-4">
<input align="center" type="text" id="quizset" class="form-control"></input>
</div>
<button class="btn btn-default col-sm-2" align="left" onclick="saveQuizSet()">Save</button>
</div>
<div class="col-sm-1">
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="container">
<div class="col-sm-12">
<div id="status">
</div>
</div>
</div>
</div>
<div class="container-fluid container-cards-pf container-pf-nav-pf-vertical
nav-pf-persistent-secondary" id="list1" style="padding-top: 0px">
<!-- LIST VIEW PART 1 -->
<div id = "div1" style="padding-top: 0px">
<?php echo form_open("Teacher/insert_quiz/$quizTitle/$quizDescription", "id='myForm'", $hidden= array()); ?>
<div>
<div class="list-group list-view-pf list-view-pf-view">
<div class="list-group-item">
<div class="list-group-item-header" id="div2">
<div class="list-view-pf-expand">
<span class="fa fa-angle-right"></span>
</div>
<div class="list-view-pf-checkbox">
<input type="text" name="questionnumber" id="inputquestionnumber1" class="form-control">
<!-- <b id="questionnumber" name="questionlabel" for="inputQuestion">Question 1: </b> -->
<input type="hidden" name="quizsetnumber" id="quizsetnum" class="form-control" value="">
</div>
<div class="list-view-pf-actions">
<?php echo form_submit('submit', 'Save', $attributes=array("class" => "btn btn-default")); ?>
<!-- <button class="btn btn-default" style="width: 100px">Save</button> -->
<button class="btn btn-default" style="width: 100px">Edit</button>
<button class="btn btn-default" style="width: 100px">Delete</button>
</div>
<div class="list-view-pf-main-info">
<div class="list-view-pf-body">
<div class="list-view-pf-description">
<div class="list-group-item-text form-group">
<input type="text" name="inputQuestion" id="input1" class="form-control">
</div>
</div>
</div>
</div>
</div>
<div class="list-group-item-container container-fluid hidden" id="containerDiv">
<div class="close">
<span class="pficon pficon-close"></span>
</div>
<div class="row">
<!-- LIST VIEW SUB VIEW -->
<div class="col-md-12">
<form class="form-horizontal" style="padding-left: 100px">
<div class="form-group">
<div class="col-sm-7" align="center">
<dt> CHOICES </dt>
</div>
<div class="col-sm-5" align="center">
<dt> CORRECT ANSWER </dt>
</div>
<div class="col-sm-7">
<div id="divCorrect" style="padding-top: 10px">
<input type="text" name="correctanswer" id="inputcorrectanswer1" class="form-control">
</div>
</div>
<div class="col-sm-5" id="divChoiceContainer1">
<div id="divChoice" style="padding-top: 10px">
<input type="text" name="inputChoice1" id="inpChoice1" class="form-control">
</div>
</div>
<div class="col-sm-7" id="otherDivChoiceContainer1">
</div>
<div class="col-sm-7" align="center" style="padding-top: 20px">
<button type="button" class="btn btn-primary btn-lg btn-block col-xs-9" id = "1" align="center" onclick="addChoiceFunction(this.id)" >Add Choices</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<?= form_close() ?>
</form>
</div>
</div>
</div>
<div class="col-sm-3 container-fluid container-cards-pf container-pf-nav-pf-vertical nav-pf-persistent-secondary">
<button type="button" class="btn btn-primary btn-lg btn-block col-md-9" align="center" onclick="addQuestionFunction()">Add Question</button>
</div>
These are the scripts I used, they're also in the quizView.php:
<script>
jQuery(document).ready(function($) {
$('#myForm').ajaxForm({
beforeSubmit: function(formData, jqForm, options){
$("div#status").html('');
},
success: function(response){
var result = $.parseJSON(response);
$("div#status").html('<div class="alert alert-' + result.status + '" role="alert"> HI </div>');
}
});
});
</script>
<script>
$(document).ready(function () {
// click the list-view heading then expand a row
$(".list-group-item-header").click(function(event){
if(!$(event.target).is("button, a, input, .fa-ellipsis-v")){
$(this).find(".fa-angle-right").toggleClass("fa-angle-down")
.end().parent().toggleClass("list-view-pf-expand-active")
.find(".list-group-item-container").toggleClass("hidden");
} else {
}
})
// click the close button, hide the expand row and remove the active status
$(".list-group-item-container .close").on("click", function (){
$(this).parent().addClass("hidden")
.parent().removeClass("list-view-pf-expand-active")
.find(".fa-angle-right").removeClass("fa-angle-down");
})
});
</script>
<script>
function addQuestionFunction() {
$num = $('div .list-view-pf-view').length + 1;
$divId = "#" + $num;
$toClone = $('#div1').clone(true).find("input").val("").end();
$($toClone).find("#containerDiv").addClass("hidden").end();
$($toClone).find("#otherDivChoiceContainer1").attr("id", "otherDivChoiceContainer"+ $num);
$($toClone).find("#otherDivChoiceContainer" + $num).find("#divChoice").remove().end();
$($toClone).find("#1").attr("id", $num);
$($toClone).find("#questionnumber").text("Question " + $num + ": ");
if($($toClone).find("span").hasClass("fa-angle-down")) {
$($toClone).find(".fa-angle-right").removeClass("fa-angle-down").end();
}
$('#list1').append($toClone);
}
function addChoiceFunction(clicked_id) {
$num = parseInt(clicked_id);
$divId = "#otherDivChoiceContainer" + $num;
$numChoice = $($divId + " input").length + 2;
$toClone = $('#divChoice').clone(true).find("input").val("").end();
$toClone.find("#inpChoice1").attr("id", "inpChoice" + $numChoice).attr("name", "inputChoice" + $numChoice);
// $toClone.find("#inpChoice" + $num).attr("name", $("#inpChoice"+$num).attr("name").replace(/\\[\d+\\]/,"inputChoice" + $num));
//alert($numChoice);
$($divId).append($($toClone));
}
function saveQuizSet() {
$('#quizsetnum').val($('#quizset').val());
$quizsetval = $('#quizset').val();
$('#divquizset').empty();
$('#divquizset').append(' <p align="center"> QUIZ SET: '+ $quizsetval + '</p>');
// $('#divquizset').append(" <p align="center"> QUIZ SET: A </p>");
}
</script>
And for my script sources I used these:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="http://malsup.github.io/jquery.form.js"></script>
<script src="http://www.patternfly.org/components/jquery/dist/jquery.min.js"></script>
<script src="http://www.patternfly.org/components/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="http://www.patternfly.org/components/patternfly-bootstrap-combobox/js/bootstrap-combobox.js"></script>
<script src="http://www.patternfly.org/components/bootstrap-datepicker/dist/js/bootstrap-datepicker.js"></script>
<script src="http://www.patternfly.org/components/bootstrap-select/dist/js/bootstrap-select.min.js"></script>
<script src="http://www.patternfly.org/components/d3/d3.min.js"></script>
<script src="http://www.patternfly.org/components/c3/c3.min.js"></script>
<script src="http://www.patternfly.org/components/datatables/media/js/jquery.dataTables.js"></script>
<script src="http://www.patternfly.org/components/google-code-prettify/bin/prettify.min.js"></script>
<script src="http://www.patternfly.org/components/clipboard/dist/clipboard.min.js"></script>
<script src="http://www.patternfly.org/components/patternfly/dist/js/patternfly.min.js"></script>
<script src="http://www.patternfly.org/components/jquery-match-height/dist/jquery.matchHeight-min.js"></script>
<script src="http://www.patternfly.org/assets/js/patternfly-site.min.js"></script>
<link rel="canonical" href="http://www.patternfly.org/pattern-library/navigation/vertical-navigation/vertical-navigation.html">
This is what my form looks like
quizviewform
And this is what it's returning
returnpage
It's inserting on my database, but it doesn't return on the page and ajax doesn't work. :( I hope someone can help me here. Thanks!

Categories