I have few containers with radio buttons. That containers have unique classes(var-wrapper-1,var-wrapper-2). I'm choosing by one radio element in different containers, but I can add 'selected' class only for one element in one container at one time. I need to choose by one radio element in each container and to add class for all selected elements in all containers. One size in size, one material from materials, and add for selected variant attr-selected css class Inside one container only one variant, but in each container has to be one selected variant. Is it possible to make it dynamic or only manually, using containers unique classes?
That's a code, which I use for only one variant in one container
jQuery('.attr-container label').click(function() {
jQuery('.attr-container label').removeClass('attr-selected');
jQuery(this).addClass('attr-selected');
});
<div class="var-wrapper-1">
<div class="label var-label">
<label for="pa_size">Size</label>
</div>
<div class="value var-value">
<div class="variation-radios">
<div class="attr-container">
<div class="radio-span" >
<input type="radio" id="attribute_pa_size-l" name="attribute_pa_size" value="s">
<label for="attribute_pa_size-l">L</label>
</div>
</div>
<div class="attr-container">
<div class="radio-span">
<input type="radio" id="attribute_pa_size-m" name="attribute_pa_size" value="m">
<label for="attribute_pa_size-m">M</label>
</div>
</div>
</div>
</div>
</div>
<div class="var-wrapper-2">
<div class="label var-label">
<label for="pa_material">Material</label>
</div>
<div class="value var-value">
<div class="variation-radios">
<div class="attr-container">
<div class="radio-span" >
<input type="radio" id="attribute_pa_material-cotton" name="attribute_pa_material" value="cotton">
<label for="attribute_pa_material-cotton">Cotton</label>
</div>
</div>
<div class="attr-container">
<div class="radio-span" >
<input type="radio" id="attribute_pa_material-lace" name="attribute_pa_lace" value="lace">
<label for="attribute_pa_material-lace">Lace</label>
</div>
</div>
</div>
</div>
</div>
.attr-selected{
font-weight: 600;
border-bottom: 1px solid grey;
}
The code is still more complex than it needs to be, please reduce its size to a minimal example as #mplungjan suggested in their comment.
If what you're asking matches my guess, you need the css :checked pseudo class. Here is an article on this topic:
https://www.w3docs.com/snippets/css/how-to-style-the-selected-label-of-a-radio-button.html
input[type="radio"]:checked {
// something
}
input[type="radio"] {
// something else
}
No Javascript is needed here
Related
I'm trying to post the implode data of multiple select html to database but it is dynamic.
Result will be like this:
data1|data2|data3 = from multiple select(already get)
how can I achieve this kind of result? It is separated with commas
data1|data2|data3, data1|data2|data3, data1|data2|data3
The separated data inside the commas come from another multiple select.
Here's my code
HTML
<div class="required field">
<label>Subjects:</label>
<select class="ui fluid search dropdown" name="pass_subj[]" multiple="">
<option value="">Subject</option>
<option value="data1">subject1</option>
<option value="data2">subject2</option>
<option value="data3">subject3</option>
<option value="data4">subject4</option>
<option value="data5">subject5</option>
</select>
</div>
<div class="two wide field" style="padding: 23px 0px 0px;">
<button class="passmore ui icon yellow button" type="button">
<i class="plus icon"></i>
</button>
</div>
php
$pass_subj = $_POST['pass_subj'];
$pass_subjs = implode("|", $pass_subj);
I solved my own problem: My current project was using fomantic-ui; on my previous attempt, I used multiple select via select tag, which gives combined array values. To fix this, I used a dropdown via a div tag:
<div class="required field">
<label>Subjects:</label>
<div class="ui multiple selection dropdown clearable">
<input name="pass_subj[]" type="hidden">
<i class="dropdown icon"></i>
<div class="default text">Subject</div>
<div class="menu">
<div class="item" data-value="AP">Araling Panlipunan</div>
<div class="item" data-value="ENG">English</div>
<div class="item" data-value="FIL">Filipino</div>
</div>
</div>
</div>
<div class="two wide field" style="padding: 23px 0px 0px;">
<button class="passmore ui icon yellow button" type="button"><i class="plus icon"></i></button>
</div>
My PHP:
$pass_subj = $_POST['pass_subj'];
$pass_subjs = implode('#',$pass_subj);
The result will be:
AP#AP,ENG#AP,ENG,FIL#AP,FIL,MATH,ENG#AP,FIL,ENG,MATH,SCI
I have code for filtration. But the data which filtered was static data. Now I want that data comes from database. Here I shown code snippet for that.
here is the script:
<script>
$('document').ready(function(){
$('#demo').jplist({
itemsBox: '.list'
,itemPath: '.list-item'
,panelPath: '.jplist-panel'
});
});
</script>
and this is the html design:
<div
class="jplist-group"
data-control-type="checkbox-group-filter"
data-control-action="filter"
data-control-name="themes">
<input
data-path=".architecture"
id="architecture"
type="checkbox"
/>
<label for="architecture">Architecture</label>
<input
data-path=".christmas"
id="christmas"
type="checkbox"
/>
<label for="christmas">Christmas</label>
</div>
<!-- item 1 -->
<div class="list-item box">
<!-- img -->
<div class="img left">
<img src="img/thumbs/arch-2.jpg" alt="" title=""/>
</div>
<!-- data -->
<div class="block right">
<p class="date">03/18/2012</p>
<p class="title">Architecture</p>
<p class="desc">Architecture is both the process and product of planning, designing and construction. Architectural works, in the material form of buildings, are often perceived as cultural symbols and as works of art. Historical civilizations are often identified with their surviving architectural achievements.</p>
<p class="like">25 Likes</p>
<p class="theme">
<span class="architecture">Architecture</span>,
<span class="brown">Brown</span>
</p>
</div>
</div>
Thanks in advance.
Is there a bootstrap class that will fill however many columns have not already been taken?
for example i have this div tag that might be there and it might not if it isnt i want the second div to take up 12 columns, but if it is there only take up 8 columns. like this
<div class="row">
<?php if(something){ ?>
<div class="col-md-4">
<div> </div>
</div>
<?php } ?>
<div class="col-md-fill">
<div> </div>
</div>
</div>
other than using
<div class="col-md-<?php
if($count > 5){
echo "8";
} else {
echo '12';
}
?>">
Sometimes I try something very stupid, but this time my stupidity surprises me...
I've seen than if we append to a div.row a div without any class, this no-class div fills herself the empty space....
Fiddle : http://jsfiddle.net/bhgme789/1/
HTML:
<div class="container">
<div class="row">
<div class="col-md-4 bleu">bleu</div>
<div class="rouge">rouge</div>
</div>
<div class="row">
<div class="col-md-1 bleu">bleu</div>
<div class="rouge">rouge</div>
</div>
<div class="row">
<div class="col-md-9 bleu">bleu</div>
<div class="rouge">rouge</div>
</div>
</div>
You're on the right track. Just finish your if statement with an else. One way, it uses a 4 and 8, the other it uses a 12 and takes up the whole row.
<div class="row">
<?php if(something){ ?>
<div class="col-md-4">
<div> </div>
</div>
<div class="col-md-8">
<div> </div>
</div>
<?php } else { ?>
<div class="col-md-12">
<div> </div>
</div>
<?php } ?>
</div>
When using Bootstrap v4 and v5 you should make use of the 'equal-width' column class col:
.col{
flex: 1 0 0%;
}
I needed this for edge cases where the last column was pushed to the next line caused by rounding errors when the browser calculates the with in pixes using the percentage based column styles. So in some situations my last column with col-2 was pushed down, using just col solved it.
A fiddle like the earlier given example with blue and red cells: http://jsfiddle.net/o14qh386/
I would do it like that, to keep code dry
<div class="row">
<div class="<?php if($something){echo 'col-md-push-4 col-md-8'}else{echo 'col-md-12'}">
</div>
</div>
I now noticed that you might want to put something if is in 4. in this case this might not be useful. If you just want to fulfil the space this is your solution
i work on web application in php. The application will be the estimates of works on roof. the app is app.tettosano.com/php_test/ when the user select its roof, then draw the roof on google maps, useful for measure the roof's area, and then on the basis of the choice of the roof, the user can make customizations.
Now, the code not work, there is no passage of value, but the code of choice the roof is
<div class="container">
<!--<div class="carousel slide" id="myCarousel">-->
<div class="carousel-inner" style="margin-left:1px !important;">
<div class="item active">
<form action="rooftype1.php" method="get">
<?php
$sql=mysql_query("select * from add_building where btype = '" . $buiding_type ."'");
while($row=mysql_fetch_array($sql))
{
?>
<ul class="thumbnails">
<li>
<div class="thumbnail">
<h5><?php echo $row['bname'] ?></h5>
<img src='admin/upload/<?php echo $row['bimage'];?>'/>
<div class="caption">
<p>Far far away behind the world mountains, far from the countries.</p>
</div>
<div> <label class="checkbox">
<input type="checkbox" value="<?php echo $row['b_id']; ?>" name="check" > Seleziona il tetto
</label></div>
<div> Esiste la copertura in amianto ?</div>
<div>
<label class="radio"><input type="radio" /> Si</label>
<label class="radio"><input type="radio" /> No</label>
</div>
</div>
</li>
<?php } ?>
</ul>
</div>
</div>
</div>
</div>
I would need a function that checks the value of my roof that was selected and give me the output can be customized.
How can i to solve this issue?
I'm working with html, php and bootstrap to create some lists and buttons. My first questions is that I have written a script populate a "select" drop down list. It should go to the "sounds/" directory and populate itself with .wav files. The "select" shows up properly, it just doesn't populate the list. I do have .wav files in the directory and I gave full permissions to the directory itself. So its not that.
My other question is how would I put a button inline with the the "select" drop down. I don't want on the next line down.
<!--CALL TAB-->
<div id="call">
<div class="container">
<div class="hero-unit">
<h5>Call Functions -</h5>
<h6>Test Paragraph</h6>
<br>
<h6> Select a Sound One -</h6>
<div class="row">
<div class="span2">
<select id="sound1">
<?php
foreach(glob('sounds/*.wav') as $filename){
$rest = substr($filename, 7);
echo "<option>".$rest."</option>";
}
?>
</select>
</div>
</div>
<br>
<h6> Select a Sound Two -</h6>
<div class="row">
<div class="span2">
<select id="sound2">
<?php
foreach(glob('sounds/*.wav') as $filename){
$rest = substr($filename, 7);
echo "<option>".$rest."</option>";
}
?>
</select>
</div>
</div>
<br>
<h6>Volume - </h6>
<div id="slider-range-max">
</div>
<div class="row">
<div class="span6">
<br>
<p><a class="btn btn-large btn-primary" href="index.html">Play <i class="icon- play"></i></a> <a class="btn btn-large btn-danger" href="index.html">Pause <i class="icon-pause"></i></a>
</div>
</div>
</div>
<hr>
<footer>
<p>© FOOTER</p>
</footer>
</div>
</div>
Getting the button next to the select is simple. If you're not styling the select or button to be a block element, then they should appear next to each other (inline block). If the HTML below doesn't work for you (button is not next to select), then try adding float: left; to both the select and button.
For your glob(), are you sure the path is correct? Where is the PHP file that's executing this versus the sounds folder? What's your directory structure?
http://jsfiddle.net/3JQeZ/
<div class="row">
<div class="span2">
<select id="sound1">
<option>1 option</option>
<option>2</option>
<option>3</option>
</select>
<button>Button</button>
</div>
</div>