Working Mootools Drag-Drop and Sort after drop. Need ID replace after sort to track input order - mootools

Description:
Drag and drop form elements to build a form that will be displayed later.
Needed:
- input and textarea formfields need to have id's in order after they have been sorted. I need to reference the answer to the questions and the instructions. Right now if they are sorted, I would not know what order to display them in later when viewing the record. there may be a better way, but Im stuck now.
Sort issue: The sortable area does not work until after the drag drop event. There are default fields that need to be sorted right away.
Here is the fiddle: http://jsfiddle.net/htscraig/vhkGD/3/
<div class="vf">
<div id="edit_menu">
<p style="text-align: center; margin: -5px 5px 5px;">Form Elements Menu</p>
<button href="#" id="questions_toggle" style="margin-left: 9px;">Questions<span id="questions_status"> show</span>
</button>
<button id="answers_toggle" href="#">Answer Type<span id="answers_status"> show</span>
</button>
<button id="instructions_toggle" href="#">Instructions<span id="instructions_status"> show</span>
</button>
<div id="questions">
<div style="text-align: center;">
<h3>VF-300 Questions<h3></div>
<div class="item">
<li style="float:left, height:40px, width:200px">
<textarea class="" cols="43" rows="3"style="border: medium none; width: 240px;" name="vf300-Q1" form="GeneralVerdict">Did <? echo $all_pla;?> and <? echo $all_def;?> enter into a contract?</textarea>
</li>
<span class="delete"><button>Delete Line</button></span>
</div>
<div class="item">
<li style="float:left, height:40px, width:200px">
<textarea class="mooeditable" cols="43" rows="4" style="border: medium none; width: 240px;" name="vf300-Q2" form="GeneralVerdict">[Did <? echo $all_pla;?> do all, or substantially all, of the significant things that the contract required <? echo "[him/her/it]";?> to do?</textarea>
</li>
<span class="delete"><button>Delete Line</button></span>
</div>
<div class="item">
<textarea class="mooeditable" cols="43" rows="6" style="border: medium none; width: 240px;" name="vf300-Q3" form="GeneralVerdict">[or]
[Was <? echo $all_pla;?> excused from having to do all, or substantially all, of the significant things that the contract required <? echo "[him/her/it]";?> to do?</textarea>
<span class="delete"><button>Delete Line</button></span>
</div>
<hr>
</div>
<div id="answers">
<div style="text-align: center;"><h3>VF-300 Answer Formats<h3></div>
<div class="item">
<input type="radio" value="Yes" name="yes-no" style="width: 20px ! important; margin-left: 30px; margin-bottom: 4px;">Yes
<input type="radio" value="No" name="yes-no" style="width: 20px ! important; margin-left: 30px; margin-bottom: 4px;">No
<span class="delete" style="opacity: 0.7;"><button>Delete Line</button></span>
</div>
<div class="item"><span>Answer 222222</span>
<span class="delete"><button>Delete Line</button></span>
</div>
<div class="item"><span>Answer 333333</span>
<span class="delete"><button>Delete Line</button></span>
</div><hr>
</div>
<div id="instructions">
<div style="text-align: center;"><h3>Juror Instructions<h3></div>
<div class="item"><textarea class="" cols="43" rows="5" style="border: medium none; width: 240px; margin-left: 15px;" name="vf300-i2" form="GeneralVerdict">If your answer to [either option for] question 2 is yes, then answer question 3. If you answered no [to both options], stop here, answer no further questions, and have the presiding juror sign and date this form.]</textarea>
<span class="delete"><button>Delete Line</button></span>
</div>
<div class="item"><textarea class="" cols="43" rows="4" style="border: medium none; width: 240px; margin-left: 15px;" name="vf300-i3" form="GeneralVerdict">If your answer to question 3 is yes, then answer question 4. If you answered no, stop here, answer no further questions, and have the presiding juror sign and date this form.]</textarea>
<span class="delete"><button>Delete Line</button></span>
</div>
<div class="item"><textarea class="" cols="43" rows="5" style="border: medium none; width: 240px; margin-left: 15px;" name="vf300-i4" form="GeneralVerdict">If your answer to [either option for] question 4 is yes, then answer question 5. If you answered no [to both options], stop here, answer no further questions, and have the presiding juror sign and date this form.</textarea>
<span class="delete"><button>Delete Line</button></span>
</div><hr>
</div>
</div>
<div id="edit_right">
<div class="info"><h1>CoPO Verdict Builder</h1>Drag and drop form elements in box. Drag elements into position to sort</div>
<ol>
<div id="edit_area">
<div class="item_dz" id="1">
<li style="float:left, height:40px, width:200px">
<textarea class="" cols="43" rows="3"style="border: medium none; width: 240px;" name="vf300-Q1" form="GeneralVerdict">Did <? echo $all_pla;?> and <? echo $all_def;?> enter into a contract?</textarea>
</li>
<span class="delete"><button>Delete Line</button></span>
</div>
<div class="item_dz">
<input type="radio" value="Yes" name="yes-a1" style="width: 20px ! important; margin-left: 30px; margin-bottom: 4px;">Yes
<input type="radio" value="No" name="no-a1" style="width: 20px ! important; margin-left: 30px; margin-bottom: 4px;">No
<span class="delete" style="opacity: 0.7;"><button>Delete Line</button></span>
</div>
<div class="item_dz">
<li style="float:left, height:40px, width:200px">
<textarea class="" cols="43" rows="4" style="border: medium none; width: 240px;" name="vf300-Q2" form="GeneralVerdict">[Did <? echo $all_pla;?> do all, or substantially all, of the significant things that the contract required <? echo "[him/her/it]";?> to do?</textarea>
</li>
<span class="delete"><button>Delete Line</button></span>
</div>
<div class="item_dz">
<input type="radio" value="Yes" name="yes-a2" style="width: 20px ! important; margin-left: 30px; margin-bottom: 4px;">Yes
<input type="radio" value="No" name="no-a2" style="width: 20px ! important; margin-left: 30px; margin-bottom: 4px;">No
<span class="delete" style="opacity: 0.7;"><button>Delete Line</button></span>
</div>
<div class="item_dz">
<textarea class="" cols="43" rows="6" style="border: medium none; width: 240px; margin-left: 15px;" name="vf300-Q3" form="GeneralVerdict">[or]
[Was <? echo $all_pla;?> excused from having to do all, or substantially all, of the significant things that the contract required <? echo "[him/her/it]";?> to do?</textarea>
<span class="delete"><button>Delete Line</button></span>
</div>
<div class="item_dz">
<input type="radio" value="Yes" name="yes-a2b" style="width: 20px ! important; margin-left: 30px; margin-bottom: 4px;">Yes
<input type="radio" value="No" name="no-a2b" style="width: 20px ! important; margin-left: 30px; margin-bottom: 4px;">No
<span class="delete" style="opacity: 0.7;"><button>Delete Line</button></span>
</div>
<div class="item_dz"><textarea class="" cols="43" rows="5" style="border: medium none; width: 240px; margin-left: 15px;" name="vf300-i2" form="GeneralVerdict">If your answer to [either option for] question 2 is yes, then answer question 3. If you answered no [to both options], stop here, answer no further questions, and have the presiding juror sign and date this form.]</textarea>
<span class="delete"><button>Delete Line</button></span>
</div>
</div>
</div>
</ol>
</div>
window.addEvent('domready', function () {
$$('.item').addEvent('mousedown', function (event) {
if (event.target == this.getParent().getElement('.delete button')) return;
event.stop();
// `this` refers to the element with the .item class
var item = this;
var clone = item.clone().setStyles(item.getCoordinates()).setStyles({
opacity: 0.7,
position: 'absolute'
}).inject(document.body);
var drag = new Drag.Move(clone, {
droppables: $('edit_area'),
onDrop: function (element, droppable) {
if (!droppable) {
item.removeClass('item_dz');
item.addClass('item');
item.tween('background-color', '#c0c0c0', '#fff');
} else {
item.removeClass('item');
item.addClass('item_dz');
item.clone().inject(edit_area);
edit_area.highlight('#4679BD', '#AFD2FF');
item.removeClass('item_dz');
item.addClass('item');
var mySortables = new Sortables('', {
clone: true,
opacity: 0.4,
});
setTimeout(function () {
mySortables.addLists(edit_area);
}, 1);
}
element.dispose();
},
onEnter: function (dragging, edit_area) {
edit_area.tween('background-color', '#9FFF8F');
},
onLeave: function (dragging, edit_area) {
edit_area.tween('background-color', '#fff');
},
onCancel: function (dragging) {
dragging.destroy();
edit_area.tween('background-color', '#fff');
}
});
drag.start(event);
});
$$('.delete').addEvents({
mouseover: function () {
this.tween('opacity', '1');
this.getParent(['.item_dz']).fade(0.3);
this.getParent(['.item_dz']).tween('background-color', '#fff', '#FF9F9F');
},
mouseleave: function () {
this.tween('opacity', '0.7');
this.getParent(['.item_dz']).fade(1);
this.getParent(['.item_dz']).tween('background-color', '#FF9F9F', '#fff');
}
});
// start delegation relays
window.addEvent('click:relay(.delete)', function () {
if (confirm('Delete this line item?')) {
this.getParent(['.item_dz']).destroy();
this.destroy();
} else {
// Do nothing
}
})
window.addEvent('mouseover:relay(.delete)', function () {
this.tween('opacity', '1');
this.getParent(['.item_dz']).fade(0.3);
this.getParent(['.item_dz']).tween('background-color', '#fff', '#FF9F9F');
})
window.addEvent('mouseleave:relay(.delete)', function () {
this.tween('opacity', '0.7');
this.getParent(['.item_dz']).fade(1);
this.getParent(['.item_dz']).tween('background-color', '#FF9F9F', '#fff');
})
//end delegation relays
// menu toggle menus start
var status = {
'true': ' show',
'false': ' hide'
};
// questions slide start
var questionsSlide = new Fx.Slide('questions');
// set default slide as hidden
questionsSlide.hide();
$('questions_toggle').addEvent('click', function (event) {
event.stop();
questionsSlide.toggle();
$('questions_status').set('text', status[questionsSlide.open]);
});
// questions slide end
// answers slide start
var answersSlide = new Fx.Slide('answers');
// set default slide as hidden
answersSlide.hide();
$('answers_toggle').addEvent('click', function (event) {
event.stop();
answersSlide.toggle();
$('answers_status').set('text', status[answersSlide.open]);
});
// answers slide end
// instructions slide start
var instructionsSlide = new Fx.Slide('instructions');
// set default slide as hidden
instructionsSlide.hide();
$('instructions_toggle').addEvent('click', function (event) {
event.stop();
instructionsSlide.toggle();
$('instructions_status').set('text', status[instructionsSlide.open]);
});
// instructions slide end
// menu toggle menus end
$('textarea').mooEditable();
});

The sortables is only added after the first drop event. To have the .item_dz sortable from the beggining you can add this line directly after the domeready function opening: http://jsfiddle.net/ke7nq/
var sortableItem_dz = new Sortables().addItems($$('.item_dz'));
I would suggest you change the HTML for .item_dz a bit so it would include both the question and the Yes/No element. Something like the exmple under so each block would be inside a item_dz:
<div class="item_dz">
<textarea class="" cols="43" rows="6" style="border: medium none; width: 240px; margin-left: 15px;" name="vf300-Q3" form="GeneralVerdict">[or] [Was <? echo $all_pla;?> excused from having to do all, or substantially all, of the significant things that the contract required <? echo "[him/her/it]";?> to do?</textarea>
<span class="delete"><button>Delete Line</button></span>
<input type="radio" value="Yes" name="yes-a2b" style="width: 20px ! important; margin-left: 30px; margin-bottom: 4px;" />Yes
<input type="radio" value="No" name="no-a2b" style="width: 20px ! important; margin-left: 30px; margin-bottom: 4px;">No<span class="delete" style="opacity: 0.7;" />
<button>Delete Line</button>
</span>
</div>
To get all the elements after you are done dropping/sorting you can do
var questions = document.getElements('.item_dz');
// or to get just the ID's:
// var questions = document.getElements('.item_dz').map(function(el){ return el.get('id'); });
or use the .serialize() method: http://mootools.net/docs/more/Drag/Sortables#Sortables:serialize

Related

How to place images in the same row in a masonry layout after filtering them with checkbox?

I am building a project with laravel. The layout is pretty similar to the Pinterest layout (also known as masonry) and it shows different types of rooms:
The layout was implemented in such a way that the images are placed in horizontal order. To do that I followed this tutorial.
This is the code for the layout:
HTML:
<script src="https://unpkg.com/masonry-layout#4/dist/masonry.pkgd.min.js"></script>
<div class="grid products-by-room" data-masonry='{ "itemSelector": ".grid-item"}' style="margin-top: 8rem">
#foreach ($rooms as $room)
<div class="grid-item" data-category="{{ $room->data_category}}" style="border: 7px solid #fff">
<a href="#zoomImg{{ $room->id }}" data-bs-toggle="modal" data-bs-target="#zoomImg{{ $room->id }}">
<div class="img-wrapper">
<img src="{{ $room->img }}" alt="" class="img-fluid shade">
<div class="overlay">
<i class="fa fa-search-plus icon"></i>
</div>
</div>
</a>
<div class="text-left mt-3 mb-5">
<p class="product-subtitle">{{ $room->name }}</p>
<h4 class="product-title">Shop the Look</h4>
<a class="product-price-link" href="#getPriceByRoom{{ $room->id }}" data-bs-toggle="modal" data-bs-target="#getPriceByRoom{{ $room->id }}">get price</a>
</div>
</div>
#endforeach
</div>
CSS:
.grid-item img {
width: 100%;
font-size: 0;
}
.grid-item {
width: 100%;
}
#media (min-width: 768px) {
.grid-item {
width: 33.333%;
}
}
I created a filter that displays only the rooms that are checked, but it is not working as I intended. It does filter the rooms correctly, but it leaves a lot of empty spaces around them.
This is the filter:
HTML:
<div class="modal-backdrop-filters"></div>
<div id="mySidenav" class="sidenav">
<div class="top-header-filters">
<h3 class="title-filters">FILTERS</h3>
<a id="closebtn" class="closebtn filter-close-btn">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"
style="border: none; background-color: #fff;">
<span aria-hidden="true">×</span>
</button>
</a>
</div>
<div class="header-filters">
<h4 class="title-filters">Categories</h4>
</div>
<div class="round" id="r-group">
<form>
<label class="label-filter" style="margin-top: 3rem;"><input type="checkbox" name="room" value="office"><span class="label-text"> Office</span></label><br>
<label class="label-filter"><input type="checkbox" name="room" value="bedroom"/><span class="label-text">Bedroom</span></label><br>
<label class="label-filter"><input type="checkbox" name="room" value="living-room"/><span class="label-text">Living Room</span></label><br>
<label class="label-filter"><input type="checkbox" name="room" value="dining-room"/><span class="label-text">Dining Room</span></label><br>
<label class="label-filter"><input type="checkbox" name="room" value="library"/><span class="label-text">Library</span></label><br>
<label class="label-filter"><input type="checkbox" name="room" value="hallway"/><span class="label-text">Hallway</span></label><br>
<label class="label-filter"><input type="checkbox" name="room" value="kitchen"/><span class="label-text">Kitchen</span></label><br>
<label class="label-filter"><input type="checkbox" name="room" value="bar"/><span class="label-text">Bar</span></label><br>
<label class="label-filter"><input type="checkbox" name="room" value="entryway"/><span class="label-text">Entryway</span></label><br>
</form>
</div>
<button id="applyBtn" class="apply-filters-btn">APPLY</button>
</div>
</div>
SCRIPT:
$(function(){
$('form').find("input").on('change',function(){
let selected = [];
$('form').find("input").each(function(){
if(jQuery(this).is(":checked")){
selected.push(jQuery(this).val());
}
})
if(!selected.length){
$(".products-by-room > div").show();
return;
}
$(".products-by-room > div").hide();
$(".products-by-room > div").each(function(){
const category = jQuery(this).attr('data-category');
const categorySplitted = category.split(' ');
categorySplitted.forEach((cat)=>{
if(selected.indexOf(cat) !== -1){
jQuery(this).show();
}
});
});
});
});
The problem is, when I select a room such as "dining room" this is the result I get, the images are shown in their original spot and lots of white spaces aroun them:
This is the result I intended, all dining rooms in the same row, with no spaces around:
Is there a way I can achieve this? Thanks in advance!

How to add indexing marks and values to input type range

Hi I'm trying to add a label to the range slider I had tried using options but it is not working.
How can I make range value 100% it is showing an overall 4% because of Max="4" i want to increase 25% every slide and make it 100% in 4 steps
Can anyone suggest to me how do I add a label to the range slide.
var slider = document.querySelector('#slider');
function range_change_event() {
var percent = slider.value;
lbl.textContent = percent + '%';
}
slider.addEventListener('input', range_change_event);
<input id="slider" type="range" min="1" max="4" step="0" list="volsettings" />
<label id="lbl" id="value" for="slider">0%</label>
<datalist id="volsettings">
<option>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
</datalist>
</div>
Trying to achieve desire output
¿something like this?
<div style="width: 300px">
<input style="width: 100%;" id="slider" type="range" min="0" max="100" step="25" />
<div style="width: 100%; display: inline-block; padding-left: 8px;">
<div style="display: inline-block; width:24%; float:left;">|</div>
<div style="display: inline-block; width:24%; float:left;">|</div>
<div style="display: inline-block; width:24%; float:left;">|</div>
<div style="display: inline-block; width:24%; float:left;">|</div>
<div style="display: inline-block; float: left;">|</div>
</div>
<div style="width: 100%; display: inline-block; padding-left: 5px;">
<div style="display: inline-block; width:24%; float:left;">0</div>
<div style="display: inline-block; width:24%; float:left;">1</div>
<div style="display: inline-block; width:24%; float:left;">2</div>
<div style="display: inline-block; width:24%; float:left;">3</div>
<div style="display: inline-block; float: left;">4</div>
</div>
</div>
<label id="lbl" id="value" for="slider" list="volsettings"></label>
<br />
<label id="lbl2" id="value" for="slider" list="volsettings"></label>
<script>
var slider = document.querySelector('#slider');
range_change_event();
function range_change_event() {
var percent = slider.value;
lbl2.textContent = (percent / 25);
lbl.textContent = percent + '%';
}
slider.addEventListener('input', range_change_event);
</script>

Specific HTML tag into button

i am working on my html php game and i have a button design what do not contain button HTML tag. But i want to give it a button functionality.
Here is HTML code of button what works and do a function to reset time for specific amount of game gold.
<form action="game.php?page=buildings" method="post" class="build_form">
<input type="hidden" name="queuetype" value="1">
<input type="hidden" name="cmd" value="fast">
<button type="submit" class="build_submit onlist tooltip" data-tooltip-content="Price : {if $need_dm<10}{10}{else}{pretty_number($need_dm)}{/if}" style="float: right; line-height: 18px; margin-right: 13px;">
<img src="./styles/images/arrowTG.png" alt="" width="16" height="16">
</button>
</form>
And here is my new button style witch i need to apply the same function as i have set for the button before this.
<tr class="data">
<td colspan="2">
<a class="build-faster dark_highlight building disabled">
<div class="build-faster-img" alt="Reset time"></div>
<span class="build-txt">Reset time</span>
<span class="dm_cost overmark">{if $need_dm<10}{10}{else}{pretty_number($need_dm)}{/if} AM</span>
<span class="order_dm">Purchase with gold</span>
</a>
</td>
</tr>
Can someone please tell me what should i do in my case and is it even possible ?
Or i need to use only button tag ?
For semantic reasons (which help a lot of users who rely on screen readers and other assitive technologies), you really should use a <button>, but you can do what you want by simply applying a click event handler to the "fake button" and in that handler, you manually call the submit event of the form.
As a side note, you should definitely not be using a table for this. Tables are for tabular data rendering, not for layout.
var form = document.querySelector("form");
var fakeSubmit = document.getElementById("fakeSubmit");
fakeSubmit.addEventListener("click", function(){
form.submit();
});
#fakeSubmit {
border:1px solid #a0a0a0;
border-radius:1px;
padding:2px 5px;
background-color:#f0f0f0;
cursor:pointer;
box-shadow:1px 1px 1px rgba(0,0,0,.5);
}
#fakeSubmit:hover, #fakeSubmit:active {
box-shadow:-1px -1px 1px rgba(255,255,255,.5);
}
<form action="game.php?page=buildings" method="post" class="build_form">
<input type="hidden" name="queuetype" value="1">
<input type="hidden" name="cmd" value="fast">
<button type="submit" class="build_submit onlist tooltip"
data-tooltip-content="Price : {if $need_dm<10}{10}{else}{pretty_number($need_dm)}{/if}"
style="float: right; line-height: 18px; margin-right: 13px;">
<img src="./styles/images/arrowTG.png" alt="some image" width="16" height="16">
</button>
<div id="fakeSubmit" class="build_submit onlist tooltip"
data-tooltip-content="Price : {if $need_dm<10}{10}{else}{pretty_number($need_dm)}{/if}"
style="float: right; line-height: 18px; margin-right: 13px;">
<img src="./styles/images/arrowTG.png" alt="some image" width="16" height="16">
</div>
</form>

Keep div fixed only inside another div and dont let it go outside parent div

I have a div element inside another div called fixed. What I want is to keep div fixed scrollable. Here is a CSS for fixed div:
#fixed
{
overflow:scroll;
position:fixed;
height:450px;
}
HTML code:
<form name="myForm" class="formcss" method="POST" action="create3.php" id="reportform" enctype="multipart/form-data">
<fieldset>
<img src="img/stuff.png" style="margin-left:35%; width:320px;">
<div class="large-3 columns" style="margin-top:1.5%;" id="fixed">
<label>Choose username</label>
<input placeholder="Search Me" id="box" type="text" />
<select>
<option disabled selected>Sort By</option>
<option value="new">Free Artists</option>
<option value="asc">Artists with 1 project</option>
<option value="desc">Artists with 1+ projects</option>
</select>
<input type='checkbox' value="ft" onclick="getUsers('sort',this.value)">FT</input>
<input type='checkbox' value="ct" onclick="getUsers('sort',this.value)">CT</input>
<input type='checkbox' value="ap" onclick="getUsers('sort',this.value)">AP</input>
<input type='checkbox' value="ct3" onclick="getUsers('sort',this.value)">CT-3</input>
<input type='checkbox' value="ct6" onclick="getUsers('sort',this.value)">CT-6</input>
<div id="myAccordion">
<?php //for($i=321; $i<347; $i++)
//{
//echo "<h3>".chr($i)."</h3>";
echo "<h3>Names</h3>";
echo '<ul class="source">';
$sql = "SELECT username FROM user ";
$result = $conn->query($sql);
if ($result->num_rows > 0)
{
// output data of each row
while($row = $result->fetch_assoc())
{
$name= $row["username"];
echo"<li class='item'><span class='closer'>x</span>".$name."</li>";
}
}
else
{
echo "0 results";
}
echo '</ul>';
//}
?>
</div>
</div>
<label>Project <?php echo $code?></label>
<div class="rowone">
<div class="projLeader">
<label>Captain:</label>
<ol>
<li class="placeholder" name="projLeader"><div class="adding">Drop Here</div></li>
<input type="hidden" name="projLeader" class="hiddenListInput1" required/>
</ol>
</div>
<div class="info">
<label>Information:</label>
<ol>
<li class="totalinfo">Total: 0.</li>
<li class="leaderinfo">Process Leaders: 0.</li>
<li class="checkerinfo">Process Checkers: 0.</li>
<li class="staffinfo">Process Artists: 0.</li>
</ol>
</div>
<div class="projChecker">
<label>Coordinator:</label>
<ol>
<li class="placeholder" name="projChecker"><div class="adding">Drop Here</div></li>
<?php
//echo '<li class="dropClass" name="projChecker"> <span class="closer">x</span>'.$_SESSION['projChecker'].'</li>';
?>
<input type="hidden" name="projChecker" class="hiddenListInput2" required/>
</ol>
</div>
</div>
<div class="rowtwo">
<?php
for($y=0;$y<$len;$y++)
{
echo "<div class='proc'> <pre>";
echo "<h6 >Process: ".$proc[$y]." " ;
echo "People required: ".$num[$y].". ";
echo "<span class='assigned' name='assigned[]' >People Assigned: 0. </span> <input class='unchecked' id='unchecked' type='hidden' name='link[]' value='0'/><input class='checked' id='checked' type='checkbox' name='link[]' value='1'><i title='Activate Process' class='fi-link'></i>Link Process</input></h6></pre>";
?>
<div class="procLeader">
<label>Leader:</label>
<ol>
<li class="placeholder"><div class="adding">Drop Here</div></li>
</ol>
</div>
<div class="procChecker">
<label>Checker:</label>
<ol>
<li class="placeholder"><div class="adding" >Drop Here</div></li>
</ol>
</div>
<div class="procStaff">
<label>Artist:</label>
<ol>
<li class="placeholder"><div class="adding">Drop Here</div></li>
</ol>
</div>
<!--<div class="small-8 large-8 columns" style="margin-left: 15%;">
<div class="form-group">
<label>Studio: <small id="small">*</small>
<div class="multiselect">
<div class="selectBox">
<select onclick="showCheckboxes()" class="input input1 name">
<option>-- Select an option --</option>
</select>
<div class="overSelect"></div>
</div>
<div class="scrollable" id="checkboxes">
<?php
while ($row = mysqli_fetch_array($resultStudio))
{
$row[0] = cleanOutputData($row[0]);
if(isset($studio))
{
foreach($studio as $code)
{
if($row[0] == $code)
{
$match = 1;
break;
}
else
$match = 0;
}
}
?>
<div class="row">
<div class="small-12 large-12 columns">
<label style="height: 37px; width:70%; float:left;" >
<input type='checkbox' class="checkbox" style="margin-left:5%; width:15%;" name='studio[]' id=<?php echo $row[0] ?> value="<?php echo $row[0] ?>" /><?php echo $row[0] ?>
</label>
</div>
</div>
<?php
}
mysqli_free_result($result);
?>
</div>
</div>
</label>
</div>
</div>-->
<div class="small-8 large-8 columns" style="margin-left: 25%;">
<table class="multiselect">
<tr><td><label>Studio:</label> </td></tr>
<tr>
<td >
<select class="input input1 name">
<option> -- Select Studio --</option>
<?php echo $studio ?>
</select>
</td>
<td><input id="img" class='AddNew' type="image" src="img/add.png" alt="Submit" onClick="return false;"></td>
<td><input type='button' class='AddNew' value='Add new item'></td>
</tr>
</table>
</div>
<?php
echo "</div>";
}
?>
</div>
<div class="row">
<div class="small-6 large-6 columns">
<input type = "submit" style="margin-left:300px; width:150px;" id="savebutton" name ="submit" class="button" value = "Create Project" onclick="userSubmitted = true;"/>
</div>
</div>
<div class="output1"></div>
<div class="output2" ></div>
<div class="output3"></div>
</div>
</fieldset>
</form>
What I got when i use position: fixed. But I want it to stay inside white area when I scroll down. I want it to be like this. How it can be achieved?
EDIT
after proposed solutions I edited code like that:
.formcss{
position: relative;
margin-left:65px;
margin-right:470px;
margin-top:50px;
width:90%;
}
#fixed
{
overflow:scroll;
position: absolute;
height:450px;
}
position: fixed; makes element's position relative to the browser window (so it scrolls along with it), not any other DOM element. So in your case it should be something like:
#fixed
{
overflow:scroll;
position:fixed;
left: 1rem; // your distance from left edge of the window
top: 1rem; // your distance from top edge of the window
height:450px;
}
If what you want to achieve is to make your #fixed attached to the specific area of your website and not the window, you what you are looking for is position: absolute; on the #fixed and position: relative; on it's parent, like:
.parent {
position: relative;
}
#fixed {
overflow:scroll;
position: absolute;
top: 1rem; // your distance from top edge of the parent
left: 1rem; // your distance from left edge of the parent
height:450px;
}
You can always play around with positions to understand them better.
EDIT
Compare fixed with absolute. Only difference between those two examples is second line of CSS section: position.
I couldn't recreate this example on the code provided as it contains many bugs
(like closing <input></input>), so make sure to validate it.
I hope you can achieve your desired effect following examples of code I provided for both cases.
Instead of position: fixed use position: absolute and position: relative on parent, that way element will be fixed to parent element position.
// !ONLY FOR DEMO!
$(document).ready(function() {
$('div').animate({
left: '80%',
top: '80%',
}, 5000);
});
.wrapper div {
position: relative;
background: #aaa;
width: 100px;
height: 100px;
}
.wrapper div:after {
position: absolute;
left: 10px;
bottom: 10px;
width: 15px;
height: 15px;
background: red;
content: '-^-';
}
.wrapper {
width: 100%;
height: 500px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="wrapper">
<div></div>
</div>
Here is preview
.parent {
width: 100%;
height: 500px;
background-color: #fff;
border: 1px solid gray;
position: relative;
}
.child {
box-sizing:border-box;
position: absolute;
top:0;
left:0;
color: #252525;
padding: 15px;
height: 100%;
width: 40%;
overflow-y: scroll;
background: #fff5f1;
}

Server error with HtmlService template, debugging shows nothing

I have an HTML template in my Apps Script project that I am trying to evaluate. I keep getting a server error (not very helpful), but I can't find anything while debugging. I tried the running result from getCode(), but no errors there. Then I also ran output.$out.getContent() (as described here https://developers.google.com/apps-script/html_service) which gives me the expected html output.
I would attach the HTML file but it contains a lot of variables and I have trouble creating a lean version with the error. I am hoping someone knows a better or the right way to debug these files.
The html file:
<html>
<body>
<form action="https://script.google.com/macros/s/AKfycbxHQDJoAtAjBF9uIctvmxBHv-QVpYf6f15UZf8aAnAh_1U_PzU/exec" method="POST" id="mail-form">
<table>
<tr style="background-color: #392303; font-size: large; line-height: 30px;">
<th>
<?= userForm.userName ?>
</th>
<th colspan="3">
<div width="250px" style="color: #e06c01; font-weight: lighter; float: left; text-indent: 10px;"><?= userForm.experience ?></div>
<div style="color: #FFFFFF; background-color: <?= userForm.pastColor ?>; border: 1px solid white; width: 28px; height: 28px; float: right;" title="<?= userForm.pastApplications ?>">
<center><?= userForm.pastNumber ?></center>
</div>
</th>
</tr>
<tr style="background-color: #9c9181">
<td width="100">
<center><p style="font-size:small; top: 5px; margin-bottom: 3px;">Thanks meter: <?= info.thanks ?></p></center>
<center><img alt="" src="" style="margin-bottom: 10px;"/></center>
<center><img src="<?= info.avatar ?>" style="height: 60px; margin-bottom: 10px;" /></center>
<center><p style="font-size:small; margin-bottom: 3px; margin-top: 3px;">Posts: <?= info.totalPosts ?></p></center>
<center><p style="font-size:small; margin-bottom: 3px; margin-top: 3px;">Per day: <?= info.postsPerDay ?></p></center>
<center><p style="font-size:small; margin-bottom: 3px; margin-top: 3px;">Join date: <?= info.joinDate ?></p></center>
<center><p style="font-size:small; margin-bottom: 3px; margin-top: 3px;">Last activity: <?= info.activity ?></p></center>
</td>
<td>
<center><?= userForm.onSite ?></center>
</td>
<td>
<center><?= userForm.tools + '\n' + '\n' + userForm.theHardPart ?></center>
</td>
<td width="100">
<center><?= userForm.development ?></center>
</td>
</tr>
<tr style="background-color: #392303; font-size: large; line-height: 30px;">
<td colspan="4" style="color: #e06c01; font-weight: lighter; text-indent: 10px;">Review</td>
</tr>
<tr style="background-color: #9c9181">
<td colspan="1" valign="top">
<label><input type="radio" name="review" value="approved" id="review_1">Accept</label>
</td>
<td colspan="1" valign="top">
<label><input type="radio" name="review" value="rejected" id="review_2">Reject</label><br><br>
<label><b>Reason(s) for user</b></label><br>
<label><input type="checkbox" name="reason" value="Reason1" id="requirements">Reason1</label><br>
<label><input type="checkbox" name="reason" value="Reason2" id="requirements">Reason2</label><br>
<label><input type="checkbox" name="reason" value="Reason3" id="requirements">Reason</label><br>
<label><input type="checkbox" name="reason" value="Reason4" id="requirements">Reason4</label><br>
<label><input type="checkbox" name="reason" value="Reason5" id="requirements">Reason5</label><br>
<label><input type="checkbox" name="reason" value="Reason6" id="requirements">Reason6</label><br>
</td>
<td colspan="1" style="text-indent: 3px;">
<label><b>Feedback</b></label><br>
<label><i>Rejections:</i> <b>WARNING</b> users will see this</label><br>
<label><i>Approvals:</i> only for us</label><br>
<textarea name="comments" rows="10" cols="35" id="comments"></textarea>
</td>
</tr>
</table>
<input type="hidden" name="userName" id="userName" value="<?= userForm.userName ?>"/>
<input type="hidden" name="reviewerName" id="reviewerName" value="<?= userForm.reviewer ?>"/>
<input type="hidden" name="link" id="link" value="<?= info.profile ?>"/>
<input type="hidden" name="row" id="row" value="<?= userForm.row ?>"/>
<input type="hidden" name="hash" id="hash" value="<?= userForm.hash ?>"/>
<div>
<div style="float: left;">
<input type="submit" name="submit" id="submit" value="Submit">
</div>
<div style="float: right;">
<a href="mailto:<?= mailTo ?>?subject=<?= subject ?>&body=<?= body ?>">
<b>Consult</b>
</a>
</div>
</div>
</form>
</body>
</html>
The relevant part of the script:
var htmlTemplate = HtmlService.createTemplateFromFile('DC Form');
htmlTemplate.userForm = userForm;
htmlTemplate.info = info;
htmlTemplate.mailTo = mailTo;
htmlTemplate.subject = 'CONSULT: ' + userForm.userName;
htmlTemplate.body = 'Profile link: ' + userForm.profile + '\n' + '\n';
var code = htmlTemplate.getCode();
Logger.log(code);
var html = htmlTemplate.evaluate().getContent();
EDIT:
After using the Caja Playground I found an error in this line:
<div style="color: #FFFFFF; background-color: <?= userForm.pastColor ?>; border: 1px solid white; width: 28px; height: 28px; float: right;" title="<?= userForm.pastApplications ?>">
Could it be that using scriptlets inside attributes isn't supported?
Well then, it looks like a simple missing of 'px' in the width attribute was the cause of all this trouble.
<td width="100">
It is fairly hard to locate as the error only appeared in certain conditions, probably only when that the size didn't match whatever it was. This would be why Corey G. though it had to be the variables, as the variables had to be of a certain length to trigger that width error. Headaches gone.
Without touching your html, I tried this slight variant of your .gs file:
function doGet() {
var htmlTemplate = HtmlService.createTemplateFromFile('DC Form');
var userForm = {userName: 'userName', profile: 'profile'};
htmlTemplate.userForm = userForm;
htmlTemplate.info = "info";
htmlTemplate.mailTo = "mailTo";
htmlTemplate.subject = 'CONSULT: ' + userForm.userName;
htmlTemplate.body = 'Profile link: ' + userForm.profile + '\n' + '\n';
var code = htmlTemplate.getCode();
Logger.log(code);
return htmlTemplate.evaluate();
}
This works fine for me. I suspect that something is wrong with one of the values in your variables.