This is what I have so far - JSFiddle
I want to submit the data from the form to the database and was wondering if there is any way with the code I have to submit the selected color of the note depending on the color the user has chosen.
I know how to use $_POST['x']; and all but to get the data from the clicked color div I am unsure of. Any help would be amazing!
$(document).ready(function() {
/* Listening for keyup events on fields of the "Add a note" form: */
$('.pr-body,.pr-author').on('keyup', function(e) {
if (!this.preview)
this.preview = $('.previewNote');
/* Setting the text of the preview to the contents of the input field, and stripping all the HTML tags: */
this.preview.find($(this).attr('class').replace('pr-', '.')).html($(this).val().replace(/<[^>]+>/ig, ''));
});
/* Changing the color of the preview note: */
$('.color').on('click', function() {
$('.previewNote').removeClass('yellow blue pink').addClass($(this).attr('class').replace('color', ''));
});
});
.note-wrapper {
position: relative;
height: 150px;
width: 150px;
float: left;
margin: 5px;
}
.note {
height: 150px;
padding: 5px;
width: 150px;
overflow: hidden;
font-family: Trebuchet MS, Tahoma, Myriad Pro, Arial, Verdana, sans-serif;
font-size: 18px;
-moz-box-shadow: 2px 2px 0 #333;
-webkit-box-shadow: 2px 2px 0 #333;
box-shadow: 2px 2px 0 #333;
}
.pink {
background-color: #ff99ff;
border: 1px solid #e589e5;
}
.yellow {
background-color: #FDFB8C;
border: 1px solid #DEDC65;
}
.blue {
background-color: #A6E3FC;
border: 1px solid #75C5E7;
}
.author {
bottom: 5px;
color: #666666;
font-family: Arial, Verdana, sans-serif;
font-size: 12px;
position: absolute;
right: 8px;
}
.note-form label {
display: block;
font-size: 10px;
font-weight: bold;
letter-spacing: 1px;
text-transform: uppercase;
padding-bottom: 3px;
}
.note-form textarea,
.note-form input[type=text] {
background-color: #FCFCFC;
border: 1px solid #AAAAAA;
font-family: Arial, Verdana, sans-serif;
font-size: 16px;
height: 60px;
padding: 5px;
width: 300px;
margin-bottom: 10px;
}
.note-form input[type=text] {
height: auto;
}
.color {
/* The color swatches in the form: */
cursor: pointer;
float: left;
height: 10px;
margin: 0 5px 0 0;
width: 10px;
}
#note-submit {
margin: 20px auto;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="note-wrapper">
<div id="previewNote" class="previewNote note yellow" style="left:0;top:65px;z-index:1">
<div class="body"></div>
<div class="author"></div>
<span class="data"></span>
</div>
</div>
<form action="post.php" method="post" id="note-form" class="note-form">
<label for="note-body">Text of the note</label>
<textarea name="note-body" id="note-body" class="pr-body" cols="30" rows="6"></textarea>
<label for="note-name">Your name</label>
<input type="text" name="note-name" id="note-name" class="pr-author" value="" />
<label>Color</label>
<!-- Clicking one of the divs changes the color of the preview -->
<div class="color yellow"></div>
<div class="color blue"></div>
<div class="color pink"></div>
<button id="note-submit" class="remodal-confirm">Submit</button>
</form>
Add a hidden input with name say color.
On click of color update the color value (as pointer out in the comment .css will return RGB not Hex) of the color you are chosing as value to the hidden input of the form.
On submit you have your chosen color - on your server side you can access the color value with the name of the input like any other string
Updated fiddle https://jsfiddle.net/5erjuo7o/
Note: add hidden attribute to the
<input name="note-color" hidden type="text"/><!-- to hide from view of the form-->
Related
This is the html code for the POPUP. If I print this out in a foreach function then when I press the another popup that is create from the function the css will be link together so no matter which CSS I press it will only pop up the data for the first POPUP and the second pop up will stay the same. This is what I made:
So if I press the POPUP from course 1 then the pop up will works but if I press the POPUP from Couse 2 then the POPUP from Couse 1 will pop out instate of the course 2 popup the I pressed. Is there any way to make the css individual by calling out them one by one with foreach function because the number of the course is no specific sometime have more and sometime have less so is there any way to make every popup individual for each course.
<input type="checkbox" id="show" />
<label for="show" class="show-btn"> Join Meeting </label>
<div class="container-attendence">
<label for="show" class="close-btn fas fa-times" title="close"></label>
<div class="text">Attendence Detail</div>
</div>
This is the CSS code
.show-btn{
background: #fff;
padding: 10px 20px;
font-size: 20px;
font-weight: 500;
color: #3498db;
cursor: pointer;
box-shadow: 0px 0px 10px rgba(0,0,0,0.1);
}
input[type="checkbox"]{
display: none;
}
.container-attendence{
display: none;
background: #fff;
width: auto;
padding: 30px;
box-shadow: 0 0 8px rgba(0,0,0,0.1);
}
#show:checked ~ .show-btn{
display: none;
}
#show:checked ~ .container-attendence{
display: block;
}
.container-attendence .close-btn{
font-size: 18px;
cursor: pointer;
}
.container-attendence .close-btn:hover{
color: #3498db;
}
.container-attendence .text{
font-size: 35px;
font-weight: 600;
text-align: center;
}
.container-attendence form{
margin-top: -20px;
}
.container-attendence form .data{
height: auto;
width: 100%;
margin: 40px 0;
}
form .data label{
font-size: 18px;
}
.Attendence-btn{
background:none;
border:none;
}
My question1.blade.php
.privew {
margin-bottom: 20px;
}
.questionsBox {
display: block;
border: solid 1px #e3e3e3;
padding: 10px 20px 0px;
box-shadow: inset 0 0 30px rgba(000,000,000,0.1), inset 0 0 4px rgba(255,255,255,1);
border-radius: 3px;
margin: 0 10px;
}.questions {
background: #007fbe;
color: #FFF;
font-size: 22px;
padding: 8px 30px;
font-weight: 300;
margin: 0 -30px 10px;
position: relative;
}
.questions:after {
background: #1d68a7 no-repeat left 0;
display: block;
position: absolute;
top: 100%;
width: 9px;
height: 7px;
content: '.';
left: 0;
text-align: left;
font-size: 0;
}
.questions:after {
left: auto;
right: 0;
background-position: -10px 0;
}
.questions:before, .questions:after {
background: black;
display: block;
position: absolute;
top: 100%;
width: 9px;
height: 7px;
content: '.';
left: 0;
text-align: left;
font-size: 0;
}
.answerList {
margin-bottom: 15px;
}
ol, ul {
list-style: none;
}
.answerList li:first-child {
border-top-width: 0;
}
.answerList li {
padding: 3px 0;
}
.answerList label {
display: block;
padding: 6px;
border-radius: 6px;
border: solid 1px #dde7e8;
font-weight: 400;
font-size: 13px;
cursor: pointer;
font-family: Arial, sans-serif;
}
input[type=checkbox], input[type=radio] {
margin: 4px 0 0;
margin-top: 1px;
line-height: normal;
}
.questionsRow {
background: #dee3e6;
margin: 0 -20px;
padding: 10px 20px;
border-radius: 0 0 3px 3px;
}
.button, .greyButton {
background-color: #f2f2f2;
color: #888888;
display: inline-block;
border: solid 3px #cccccc;
vertical-align: middle;
text-shadow: 0 1px 0 #ffffff;
line-height: 27px;
min-width: 160px;
text-align: center;
padding: 5px 20px;
text-decoration: none;
border-radius: 0px;
text-transform: capitalize;
}
.questionsRow span {
float: right;
display: inline-block;
line-height: 30px;
border: solid 1px #aeb9c0;
padding: 0 10px;
background: #FFF;
color: #007fbe;
}
<body>
<div class="container">
<div class="privew">
<div class="questionsBox">
<div class="questions"><h1>Something</h1></div>
<div class="answerList"><h3>You are only allowed to select one option from the given below question</h3></div>
<div class="questions"><h4>Question 1</h4></div>
<div class="questions"><h3>Section 1</h3></div>
<ul class="answerList">
<li>
<label>
<input type="radio" name="answerGroup" value="0" id="answerGroup_0">Yes</label>
</li>
<li>
<label>
<input type="radio" name="answerGroup" value="1" id="answerGroup_1">Rather yes</label>
</li>
<li>
</ul>
</div>
<div class="questionsBox">
<div class="questions"><h3>Section 2</h3></div>
<ul class="answerList">
<li>
<label>
<input type="radio" name="answerGroup" value="2" id="answerGroup_2">Yes</label>
</li>
<li>
<label>
<input type="radio" name="answerGroup" value="3" id="answerGroup_3">Rather yes</label>
</li>
</ul>
</div>
<div class="questionsRow">Next<span>1 from 20</span>Previous</div>
</div>
</div>
<script type="text/javascript">
</script>
</body>
Hello All,
I'm trying to make a test page where users will select one radio button option and submit all selections in one instance in order to store back into the database. Also, questions are on different pages so basically user can move back and forth in order to edit its selection. There are 20 questions in total. I am unable to understand where shall I put my array logic. My best guess would be in a TestController. Please drop your valuable answer.
P.S : I am a beginner in Web Development and recently started to work on a Personality assessment website Project. However, due to less experience, I am facing a lot of challenges to achieve building it.
This problem is from my Laravel 6.x Project.
I expect to get all the selections stored in an array and passed to the database where I can further process it.
When I try to display content from another blade template, it will only show certain data on the webpage. What I want is inside this page, the content from test.blade.php together with the button, when click will pop up a form(I don't want the test.blade.php content to be inside). But whenever I try to do it, only certain information is shown and when I view page source, all the data has already been loaded. I have asked this question before already and someone told me it was the fault of my css, but I when I try to look at it, I don't really see anything which is causing this to happen. Can someone help me please? Thanks in advance!
I will put the screenshot here first in the question.
This is what it is suppose to look like where it will have a scroll down bar, and below there should be a button for the popup form.
But this is what I am getting (I have checked that all the data are already loaded)
elements.css (here is the css that I used)
#abc {
width: 100%;
height: 100%;
opacity: .95;
top: 0;
left: 0;
display: none;
position: fixed;
background-color: #313131;
overflow: auto;
}
img#close {
position: absolute;
right: -14px;
top: -14px;
cursor: pointer;
}
div#popupContact {
position: absolute;
left: 50%;
top: 17%;
margin-left: -202px;
font-family: 'Raleway', sans-serif;
}
form {
max-width: 300px;
min-width: 250px;
padding: 10px 50px;
border: 2px solid gray;
border-radius: 10px;
font-family: raleway;
background-color: #fff;
}
p {
margin-top: 30px;
}
h2 {
background-color: #FEFFED;
padding: 20px 35px;
margin: -10px -50px;
text-align: center;
border-radius: 10px 10px 0 0;
}
hr {
margin: 10px -50px;
border: 0;
border-top: 1px solid #ccc;
}
input[type=text] {
width: 82%;
padding: 10px;
margin-top: 30px;
border: 1px solid #ccc;
padding-left: 40px;
font-size: 16px;
font-family: raleway;
}
#name {
background-image: url(../images/name.jpg);
background-repeat: no-repeat;
background-position: 5px 7px;
}
#email {
background-image: url(../images/email.png);
background-repeat: no-repeat;
background-position: 5px 7px;
}
textarea {
background-image: url(../images/msg.png);
background-repeat: no-repeat;
background-position: 5px 7px;
width: 82%;
height: 95px;
padding: 10px;
resize: none;
margin-top: 30px;
border: 1px solid #ccc;
padding-left: 40px;
font-size: 16px;
font-family: raleway;
margin-bottom: 30px;
}
#submit {
text-decoration: none;
width: 100%;
text-align: center;
display: block;
background-color: #FFBC00;
color: #fff;
border: 1px solid #FFCB00;
padding: 10px 0;
font-size: 20px;
cursor: pointer;
border-radius: 5px;
}
span {
color: red;
font-weight: 700;
}
button {
width: 10%;
height: 45px;
border-radius: 3px;
background-color: #cd853f;
color: #fff;
font-family: 'Raleway', sans-serif;
font-size: 18px;
cursor: pointer;
}
evaltest.blade.php
<html>
<head>
<title>Popup form </title>
<meta name="robots" content="noindex, nofollow">
<link href="{{ asset('css/elements.css') }}" rel="stylesheet">
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-43981329-1']);
_gaq.push(['_trackPageview']);
(function () {
var ga = document.createElement('script');
ga.type = 'text/javascript';
ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<!-- body starts here -->
<body id ="bdy" style="overflow:hidden;">
<div id="abc">
<!-- Popup div starts here -->
<div id="popupContact">
<!-- contact us form -->
<form class="form-horizontal" method="post" action="{{ url('/evaltest/'.$data0->id) }}">
{{ csrf_field() }}
<img id ="close" src="{{ URL::to('/image') }}/3.png" onclick ="div_hide()">
<input type="hidden" name="user_id" value="{{$data0->id}}">
<div class="form-group">
<label class="col-md-2"><b>Recommendation:</b></label>
<div class="col-md-6">
<input type="radio" id ="recommendation" name="recommendation" value="Yes"> Yes<br>
<input type="radio" id ="recommendation" name="recommendation" value="No"> No<br>
</div>
</div>
<div class="form-group">
<div class="col-md-6-offset-2">
<input id= "submit" type="submit" href="javascript: check_empty()" class="btn btn-primary" value="Save">
</div>
</div>
</form>
</div>
<!-- Popup Div Ends Here -->
// #include('test')
//it will show all data if I were to put here but I don't want to put it together with the popup form
</div>
<!-- Display Popup Button -->
//this will show a few info but no button
#include('test')
<h1>Click Button to Evaluate</h1>
<button id="popup" onclick="div_show()">Popup</button>
<script src="{{ asset('/js/my_js.js') }}"></script>
//this will show even lesser info but button is shown
//#include('test')
</body>
</html>
test.blade.php (there are more information inside but I only put some as an example of how I got the information)
<div class="container">
#foreach ($data as $object)
<b>Name: </b>{{ $object->Name }}<br><br>
<b>Alias: </b>{{ $object->Alias }}<br><br>
<b>Email: </b>{{$object->Email}}<br><br>
#endforeach
</div>
I have tried removing some of the things inside the css but nothing happen, I even try removing those with the position: fixed and also added .container but it still doesn't work.
myjs.js
// function to display popup
function div_show() {
document.getElementById('abc').style.display = "block";
}
// function to hide popup
function div_hide(){
document.getElementById('abc').style.display = "none";
}
I have figured it out how to show my data is that I have to remove the style="overflow:hidden;" part so that it will work
I am using Tipsy in my webpage to show tooltip. But it is showing Title with Tipsy css etc.. perfectly for first result but not working on another results from mysql. On Another Simple Title is shown on hover. (Please See below attached Image )
I am using following code where $data["remark"] is fetched from mysql database and used as title in code and it is working ok.
In Head
<link rel="stylesheet" href="css/tipsy.css" type="text/css" />
<script type="text/javascript" src="js/jquery.tipsy.js"></script>
In Body section
<div>
<a id='delay-example' href="#" title="<?=$data['remark']?>"
style="cursor:pointer;"> Show Remark</a>
</div>
<script type='text/javascript'>
$('#delay-example').tipsy({delayIn: 500, delayOut: 3000});
</script>
Image : -
I found Following Solution. It is working with CSS only, But Worked Perfectly At least For Me..
Code Is As Follow :
In Head Section -
<style type="text/css">
.tooltip {
border-bottom: 1px dotted #000000; color: #000000; outline: none;
cursor: help; text-decoration: none;
position: relative;
}
.tooltip span {
margin-left: -999em;
position: absolute;
}
.tooltip:hover span {
border-radius: 5px 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px;
box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.1); -webkit-box-shadow: 5px 5px rgba(0, 0, 0, 0.1); -moz-box-shadow: 5px 5px rgba(0, 0, 0, 0.1);
font-family: Calibri, Tahoma, Geneva, sans-serif;
position: absolute; left: 1em; top: 2em; z-index: 99;
margin-left: 0; width: 250px;
-webkit-transition: all 0.1s ease-out; -moz-transition: all .1s ease; -o-transition: all .1s ease;
}
.tooltip:hover img {
border: 0; margin: -10px 0 0 -55px;
float: left; position: absolute;
}
.tooltip:hover em {
font-family: Candara, Tahoma, Geneva, sans-serif; font-size: 1.2em; font-weight: bold;
display: block; padding: 0.2em 0 0.6em 0;
}
.help { background: #9FDAEE; border: 1px solid #2BB0D7; }
</style>
In Body Section -
<div>
Special Remark <a class="tooltip" href="#" style="cursor:pointer;"><img src="images/remarkhelp.png" width="15px" height="15px"/><span class="custom help"><img src="images/help.png" width="15px" height="15px"/><em>Special Remark</em> <?=$data['remark']?></span></a>
</div>
Found This HERE
You've probably used the SAME id for all of your elements. Since a DOM ID must be unique across the entire document, $('#delay-example') is properly returning the FIRST id found in your document, and ignoring all the others.
e.g.
<div id="foo">foo #1</div>
<div id="foo">foo #2</div>
$('#foo').innerText = 'hahaha not foo any more';
Would result in this html:
<div id="foo">hahaha not foo anymore</div>
<div id="foo">foo #2</div>
By comparison, using CSS classes:
<div class="foo">foo #1</div>
<div class="foo">foo #2</div>
$('.foo').innerText = 'hahaha not foo anymore';
would produce
<div class="foo">hahaha not foo anymore</div>
<div class="foo">hahaha not foo anymore</div>
I have an existing div and I want to add some new data (5 spans) to this existing div. The method I was using makes the following GUI
I want it to display the search results in existing div (in black translucent region). My HTML Code is
<title>Search your Friends</title>
<body>
<div class="title">
GTBIT's Almuni Diary
</div>
<div class="main">
<form id="myForm" method="POST">
<input placeholder="Enter some text to search"type="text" class="name" name="query">
<br>
<span class="searchby">Search Criteria</span>
<select name="criteria">
<option value="name" selected="selected">Search by Name</option>
<option value="enrno">Search by Enrollment No.</option>
<option value="email">Search by Email ID</option>
<option value="phno">Search by Phone No.</option>
</select>
<br>
<input type="button" class="search" value="Search">
</form>
<div class="sr">
Search Results
</div>
<div class="dynamicData">
<div class="header">
<span class="heading">Name</span>
<span class="heading">Email ID</span>
<span class="heading">Enrollment No.</span>
<span class="heading">Nickname</span>
<span class="heading">Batch</span>
</div>
<div class='dataDiv'>
</div>
</div>
</div>
CSS :
body
{
font-family: "source sans pro";
font-size: 20px;
background-image: url("../images/searchbg.jpg");
background-size: 100% 100%;
background-attachment: fixed;
background-repeat: no-repeat;
}
.title
{
display: none;
color: #03C9A9;
background-color: rgba(0,0,0,0.8);
padding: 5px;
font-weight: 500;
font-size: 54px;
height: 90px;
text-align: center;
}
.main
{
display: none;
width: 90%;
margin: 0 auto;
margin-top: 20px;
background-color: rgba(0,0,0,0.5);
padding: 20px;
}
.searchby, input, select
{
color: white;
font-family: inherit;
font-size: 28px;
display: inline-block;
}
.name
{
color: black;
width: 80%;
}
.searchby
{
margin-top: 40px;
}
select
{
border: 0px solid white;
margin-left: 30px;
margin-right: 30px;
color: black;
font-size: 22px;
}
.search
{
background-color: rgba(0,0,0,0.8);
color: #03C9A9;
margin: 0 auto;
margin-top: 30px;
padding: 5px;
display: block;
border: 0px solid white;
cursor: pointer;
font-size: 32px;
}
.name
{
margin-left: 10px;
border: 0px solid white;
}
.sr
{
margin-top: 75px;
font-family: inherit;
font-size: 32px;
width: 100%;
text-align: center;
background-color: rgba(0,0,0,0.8);
color: #03C9A9;
margin-bottom: 50px;
}
.dynamicData
{
width: 98%;
margin-left: 10px;
padding: 2px;
background-color: rgba(0,0,0,0.3);
}
.header
{
padding: 5px;
width: 90%;
text-align: center;
padding: 5px 0px 5px 0px;
margin: 0 auto;
}
.heading
{
background-color: #03C9A9;
color: white;
font-family: inherit;
font-size: 24px;
height: 30px;
width: 202px;
display: inline-block;
margin-bottom: 10px;
}
.dataDiv
{
padding: 2px;
width: 90%;
text-align: center;
margin: 0 auto;
}
.data
{
font-family: inherit;
font-size: 24px;
height: 30px;
width: 202px;
display: inline-block;
margin-bottom: 5px;
color: black;
background-color: rgba(255,255,255,0.75);
}
PHP Script responsible for adding (after getting data form database)
while($stmt->fetch())
{
echo "<br>
<span class='data ndata'>$nm</span>
<span class='data emaildata'>$em</span>
<span class='data enrnodata'>$eno</span>
<span class='data nicknamedata'>$nn</span>
<span class='data batchdata'>$bt</span>";
}