html forms with its model not submit - javascript

I have three buttons and three forms into their divs(Models) at one page. All divs(Models) with their forms are hidden. First time when page is loaded. One div with its ID and its form is cloned and shown into another div#replace section. Then When I try to submit it. its not submitted the form. why? see code here
here all div(Models) with its form is replace when click on button
<div class="row">
<h1 class="text-center margin-top10 fsize60"></h1>
<section class="text-center replace-section">
<!-- forms are shown here when button is click -->
</section>
$(document).ready(function() {
$("#frm_infradi_result").click().clone().removeClass('hide').addClass('show').prependTo(".replace-section");
$("button[name='btn_infradi_result']").click(function() {
$('.replace-section').empty();
$("#frm_infradi_result").click().clone().removeClass('hide').addClass('show').prependTo(".replace-section");
});
$("button[name='btn_madaris_result']").click(function() {
$('.replace-section').empty();
$("#frm_madaris_result").click().clone().removeClass('hide').addClass('show').prependTo(".replace-section");
});
$("button[name='btn_hifz_result']").click(function() {
$('.replace-section').empty();
$("#frm_hifz_result").click().clone().removeClass('hide').addClass('show').prependTo(".replace-section");
});
$("button[name='btn_nazer_sani']").on('click', function() {
$('#modal_nazer_sani').show();
});
});
<!-- 1 div#frm_infradi_result with its form -->
<div class="col-md-7 col-md-push-3 animated fadeInRight animation-delay-5 hide" id="frm_infradi_result">
<div class="panel panel-info">
<div class="panel-heading text-center">
<h3 class="h2 ur no-margin-padding" style="display: inline;">
انفرادى مکتب نتائج برائے سال 1437ھ
</h3>
<i class="fa fa-users" aria-hidden="true"></i>
</div>
<div class="panel-body">
<div class="row">
<div class="col-xs-12">
<form method="post" id="frm_result" action="mailto:itsoftsaeed#gmail.com">
<!-- here is form elements list -->
</form>
</div>
</div>
</div>
</div>
<!-- 2 div#frm_madaris_result with its form -->
<div class="col-md-7 col-md-push-3 animated fadeInRight animation-delay-5 hide" id="frm_madaris_result">
<div class="panel panel-info">
<div class="panel-heading text-center">
<h3 class="h2 ur no-margin-padding" style="display: inline;">
انفرادى مکتب نتائج برائے سال 1437ھ
</h3>
<i class="fa fa-users" aria-hidden="true"></i>
</div>
<div class="panel-body">
<div class="row">
<div class="col-xs-12">
<form method="post" id="frm_madaris" action="mailto:itsoftsaeed#gmail.com">
<!-- here is form elements list -->
</form>
</div>
</div>
</div>
</div>
<!-- 3 div#frm_hifz_result with its form -->
<div class="col-md-7 col-md-push-3 animated fadeInRight animation-delay-5 hide" id="frm_hifz_result">
<div class="panel panel-info">
<div class="panel-heading text-center">
<h3 class="h2 ur no-margin-padding" style="display: inline;">
انفرادى مکتب نتائج برائے سال 1437ھ
</h3>
<i class="fa fa-users" aria-hidden="true"></i>
</div>
<div class="panel-body">
<div class="row">
<div class="col-xs-12">
<form method="post" id="frm_hifz" action="mailto:itsoftsaeed#gmail.com">
<!-- here is form elements list -->
</form>
</div>
</div>
</div>
</div>

Related

jQuery remove text from h1

I have to build a shoppinglist where I can add and delete lists.
On the right side there is the currently opened list with the list headline.
When deleting a list, the headline should disappear, but it doesn´t, neither with empty(), nor remove() or text(' ').
I just edited the post so you can see the whole HTML code
HTML:
<div class="container">
<div class="row">
<div class="col-sm-4">
<div id="shoppinglist">
<div class="header left">
<h2>Listen</h2>
<i class="glyphicon glyphicon-plus newList" ></i>
</div>
<ul class="list lists">
<!-- -->
</ul>
</div>
</div>
<div class="col-sm-8">
<div class="header right">
<i class="glyphicon glyphicon-search"></i>
<i class="glyphicon glyphicon-menu-hamburger"></i>
<img src="img/profile.png" alt="profilbild">
</div>
<div id="listbody">
<div class="listheader">
<!--<h1>List 1</h1>-->
</div>
<div id="listitems">
<div class="items_container">
<!-- -->
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-4">
<div id="categorylist">
<div class="header">
<h2>Kategorien</h2>
</div>
<ul class="list categories">
<!-- -->
</ul>
</div>
</div>
<div class="col-sm-8">
<div class="header">
<input placeholder="Was willst du Einkaufen?" type="text" />
</div>
<div id="categoryitems">
<div class="items_container">
<!-- -->
</div>
</div>
</div>
</div>
<div id="producthover_container">
<div id='producthover'>
<div id='producthover_icon'>
<i class='glyphicon glyphicon-plus'></i>
</div>
<div id='producthover_detail'>
<span>Details <br> hinzufügen</span>
</div>
</div>
</div>
</div>
list.js:
printHeader(){
$(".listheader").empty();
$(".listheader").append("<h1 class='h1header'>" + this.name + "</h1>");
}
shoppinglist.js:
$(".lists").on("click","i",(e) =>{
let r = confirm("Delete?");
if(r) {
$(".h1header").remove();
$(e.target).parent().remove();
}
});
you have to Remove it from the parent node. like this:
var child = $(".h1header");
$(".listheader").removeChild(child);
or you will have to create a function that does this when given a child node

Bootstrap columns enlarge the more I type in a search bar

When typing in to an input search bar, my Bootstrap div .col-xs-4 enlarges, breaking out of it's container. What's odd is, Developer Tools doesn't seem to show any changes in the code that would affect this.
To replicate this problem, try typing the full name of one of the images in this JSFiddle gallery i.e., "Satcom 2016", and watch the div burst out of it's container. Clearing the input then shows that every div has expanded, not just the visible ones.
JSFiddle
https://jsfiddle.net/vadrfgvv/
jQuery
function rowBreak(input) {
$('.col-flex').hide();
if (input) {
$('.row-flex').replaceWith(function() {
return $(this).html();
});
$('.col-flex').wrapAll('<div class="row">');
}
$('.col-visible').each(function(i, e) {
if (((i + 1) % 3 == 0) && ($(this).siblings().length != 2)) {
var x = $('.col-visible:gt(' + i + ')');
$('<div class="row">').append(x).insertAfter(this.closest('div.row'));
}
});
$('.col-visible').show();
}
rowBreak(0);
$('#search').on('keyup', function() {
$('.col-flex').removeClass('col-visible').hide();
var s = $(this).val().toLowerCase();
$('.col-flex').filter(function() {
return $(this).find('h4').text().toLowerCase().indexOf(s) > -1;
}).show().addClass('col-visible');
rowBreak(s);
});
$('#results').on('click', '.panel-search', function() {
$(this).toggleClass('panel-default').toggleClass('panel-success');
$(this).find('.panel-body').toggleClass('bg-green');
var image = $(this).find('img');
var imageID = image.attr('id');
// alert(image.width());
if ($(this).hasClass('panel-success')) {
image.clone().appendTo('.panel-include').removeClass('img-thumbnail').css('margin-bottom', '20px').attr('id', 'x' + imageID).wrap('<p></p>');
} else {
$('.panel-include').find(('#x' + imageID)).closest('p').remove();
}
if ($('.panel-include > p').length == 0) {
$('.panel-include').find('em').show();
} else {
$('.panel-include').find('em').hide();
}
});
$('.btn-save').on('click', function(e) {
e.preventDefault();
var logos = '';
$('.panel-include').find('p').each(function() {
imageID = $(this).find('img').attr('id');
logos += imageID;
});
if (logos) {
logos = logos.substr(1);
}
$("input[name=ids]").val(logos);
$(this).closest('form').submit();
});
HTML
<div class="container-fluid">
<div class="form-group">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-search"></i></span>
<input class="form-control" id="search" type="text" placeholder="Search...">
</div>
</div>
<div class="row">
<div class="col-xs-3">
<div class="panel panel-primary">
<div class="panel-heading">
<h4 class="panel-title">
Your Chosen Content
</h4>
</div>
<div class="panel-body panel-include">
<em class="text-muted">Click on some images to add them here.</em>
</div>
</div>
<form action="#" method="get">
<input type="hidden" name="ids" value="">
<p class="text-right">
<button class="btn btn-primary btn-save" type="submit">
<i class="fa fa-save"></i> Save
</button>
</p>
</form>
</div>
<div class="col-xs-9">
<div id="results">
<div class="row row-flex">
<div class="col-xs-4 col-flex col-visible">
<div class="panel panel-search panel-default">
<div class="panel-heading">
<h4 class="panel-title">
AEClim
</h4>
</div>
<div class="panel-body">
<img class="img-responsive img-thumbnail img-gallery" src="http://placehold.it/160x100/cccccc/9a9a9a/&text=AEClim" id="1">
</div>
</div>
</div>
<div class="col-xs-4 col-flex col-visible">
<div class="panel panel-search panel-default">
<div class="panel-heading">
<h4 class="panel-title">
AEMET
</h4>
</div>
<div class="panel-body">
<img class="img-responsive img-thumbnail img-gallery" src="http://placehold.it/160x100/cccccc/9a9a9a/&text=AEMET" id="2">
</div>
</div>
</div>
<div class="col-xs-4 col-flex col-visible">
<div class="panel panel-search panel-default">
<div class="panel-heading">
<h4 class="panel-title">
AME
</h4>
</div>
<div class="panel-body">
<img class="img-responsive img-thumbnail img-gallery" src="http://placehold.it/160x100/cccccc/9a9a9a/&text=AME" id="3">
</div>
</div>
</div>
<div class="col-xs-4 col-flex col-visible">
<div class="panel panel-search panel-default">
<div class="panel-heading">
<h4 class="panel-title">
APMG
</h4>
</div>
<div class="panel-body">
<img class="img-responsive img-thumbnail img-gallery" src="http://placehold.it/160x100/cccccc/9a9a9a/&text=APMG" id="4">
</div>
</div>
</div>
<div class="col-xs-4 col-flex col-visible">
<div class="panel panel-search panel-default">
<div class="panel-heading">
<h4 class="panel-title">
ATC Network
</h4>
</div>
<div class="panel-body">
<img class="img-responsive img-thumbnail img-gallery" src="http://placehold.it/160x100/cccccc/9a9a9a/&text=ATC+Network" id="5">
</div>
</div>
</div>
<div class="col-xs-4 col-flex col-visible">
<div class="panel panel-search panel-default">
<div class="panel-heading">
<h4 class="panel-title">
Meteomet
</h4>
</div>
<div class="panel-body">
<img class="img-responsive img-thumbnail img-gallery" src="http://placehold.it/160x100/cccccc/9a9a9a/&text=Meteomet" id="6">
</div>
</div>
</div>
<div class="col-xs-4 col-flex col-visible">
<div class="panel panel-search panel-default">
<div class="panel-heading">
<h4 class="panel-title">
MMC 2016
</h4>
</div>
<div class="panel-body">
<img class="img-responsive img-thumbnail img-gallery" src="http://placehold.it/160x100/cccccc/9a9a9a/&text=MMC+2016" id="7">
</div>
</div>
</div>
<div class="col-xs-4 col-flex col-visible">
<div class="panel panel-search panel-default">
<div class="panel-heading">
<h4 class="panel-title">
Satcom 2016
</h4>
</div>
<div class="panel-body">
<img class="img-responsive img-thumbnail img-gallery" src="http://placehold.it/160x100/cccccc/9a9a9a/&text=Satcom+2016" id="8">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
I initially thought it was the .img-responsive class that was causing problems (maybe the image was enlarging when the div was hidden?), but it seems like the image doesn't actually enlarge with the div, so that rules that out.
I'm not sure where else to start debugging.
Note: I have kept the entirety of the Javascript that affects these page elements in my question/Fiddle, in case it is something there that is causing the problem.
.row {
margin-right: -15px;
margin-left: -15px;
}
This CSS is the cause of your problem. i didn't see exactly how, but your js code nesting a row for every character typed. and with this css in bootstrap.css each nested row grows larger and larger. the images expand too.
what you can do is, overwrite this css in your html file with <style> tag. something like:
<style>
.row{
margin-right:0px;
margin-left:0px;
}
</style>
but you should know this is only a quick fix. a hack. if i was in your place, i'd look for the reason why your code is nesting a row for every character.

Traversing the DOM to toggle a panel footer?

I'm new to jquery and I'm trying to figure out how to traverse the dom in order to toggle the collapse option on panel footers? Any pointers?
<div id="colDealDiv" class="row col-md-8 col-md-offset-2 colDiv">
<div class="panel panel-default">
<div class="panel-heading">
<p>Retail & Services</p></div>
<div class="panel-body">
<div id="thumbnailDealDiv" class="thumbnail">
<div id="captionDealDiv" class="caption">
<p>$35 -- 'Best of NY': Painting Parties at City Bars, Reg. $65</p>
<p>Paint Nite</p>
<p>New York</p>
<p>NY</p><img src="https://api.sqoot.com/v2/deals/4344628/image?api_key=demo" class="img-thumbnail">
<button class="btn btn-info" data-toggle="collapse"></button>
</div>
</div>
</div>
<div class="panel-footer collapse">
<p>46% off at Paint Nite</p>
<p>35</p>
<p>2016-05-24T13:00:00Z</p>
</div>
</div>
$(".panel").on("click", ".btn-info", function() {
$(this).parent().next(".panel-footer").collapse("toggle");
});

Bootstrap 3 Collapse on hover

I'm working on this site here. http://opennetsummit.wpengine.com/
The three images in the second section down trigger the bootstrap collapse function on click. I'd like them to show on hover, and hide when not hovering.
What do I need to change?
<script>
$(".paneltab1").hover(
function() {
$('#collapsePanel1').collapse('show');
}, function() {
$('#collapsePanel1').collapse('hide');
}
);
</script>
<div class="row panel-heading">
<div class="container">
<div class="col-xs-3">
<a class="paneltab1" data-toggle="collapse" href="#collapsePanel1" aria-expanded="false" aria-controls="collapsePanel1">
<div class="panel-tabs">
<img src="http://opennetsummit.wpengine.com/wp-content/uploads/2015/01/ons-rocket-icon.png">
<h3>Workshops</h3>
</div>
</a>
</div>
<div class="col-xs-3 ">
<a class="" data-toggle="collapse" href="#collapsePanel2" aria-expanded="false" aria-controls="collapsePanel2">
<div class="panel-tabs">
<img src="http://opennetsummit.wpengine.com/wp-content/uploads/2015/01/ons-circles-icon.png">
<h3>Open Networking Summit</h3>
</div>
</a>
</div>
<div class="col-xs-3 ">
<a class="" data-toggle="collapse" href="#collapsePanel3" aria-expanded="false" aria-controls="collapsePanel3">
<div class="panel-tabs">
<div>
<img src="http://opennetsummit.wpengine.com/wp-content/uploads/2015/01/ons-inspire-icon.png">
<h3>Webinars</h3>
</div>
</div>
</a>
</div>
<div class="col-xs-3 ">
<div class="panel-tabs">
<div class="mid-form">
<h3>Get Updates</h3>
</div>
</div>
</div>
</div>
</div>
<div class="collapse" id="collapsePanel1">
<div class="row">
<div class="container">
<div class="col-xs-12 hompage-panel">
<div class="col-sm-4 center">
<img src="http://opennetsummit.wpengine.com/wp-content/uploads/2015/01/ons-inspire-icon.png">
</div>
<div class="col-sm-8">
<h2>Defy Protocol </h2>
<h1>EMBRACE {OPEN} SOFTWARE</h1>
<h3>Open Networking Summit</h3>
<hr>
<p>June 15 - 18, 2015</p>
<p>Santa Clara Convention Center</p>
More Information
</div>
</div>
</div>
</div>
</div>
<div class="collapse" id="collapsePanel2">
<div class="row">
<div class="container">
<div class="col-xs-12 hompage-panel">
<div class="col-sm-4 center">
<img src="http://opennetsummit.wpengine.com/wp-content/uploads/2015/01/ons-inspire-icon.png">
</div>
<div class="col-sm-8">
<h2>Panel 2 </h2>
<h1>EMBRACE {OPEN} SOFTWARE</h1>
<h3>Open Networking Summit</h3>
<hr>
<p>June 15 - 18, 2015</p>
<p>Santa Clara Convention Center</p>
More Information
</div>
</div>
</div>
</div>
</div>
<div class="collapse" id="collapsePanel3">
<div class="row">
<div class="container">
<div class="col-xs-12 hompage-panel">
<div class="col-sm-4 center">
<img src="http://opennetsummit.wpengine.com/wp-content/uploads/2015/01/ons-inspire-icon.png">
</div>
<div class="col-sm-8">
<h2>Panel 3 </h2>
<h1>EMBRACE {OPEN} SOFTWARE</h1>
<h3>Open Networking Summit</h3>
<hr>
<p>June 15 - 18, 2015</p>
<p>Santa Clara Convention Center</p>
More Information
</div>
</div>
</div>
</div>
You can use jquery's hover along with bootstrap's collapse javascript, something like this:
$(".panel-tabs").hover(
function() {
$('#collapsePanel3').collapse('show');
}, function() {
$('#collapsePanel3').collapse('hide');
}
);
The first function(){} is for when the mouse enters, the second for when it leaves.
More info here:
http://api.jquery.com/hover/
http://getbootstrap.com/javascript/#collapse-methods
I changed the class from "collapse" to "collapse in" on mouseover and from "collapse in" to "collapse" on mouseout using GetElementbyID and it worked fine.
document.getElementById("panelid").className = "collapse in";

How to show a modal window with text and img clicking on a thumbnail img

I just started using Bootstrap 3. I made a thumbnail grid with images related to different projects. I would like that when clicking on an image a modal window open. In the modal I need to report image coming from thumbnail and some text explaining the project content.
Any idea, suggestion of how to do it?
Adding modals in Bootstrap is very easy, and there are examples in the Bootstrap documentation: http://getbootstrap.com/javascript/#modals.
I suggest trying out some of the examples and seeing how far you can get, and then if you get stuck you can ask for specifics.
I' coding as follow
<div class="container">
<div class="row">
<div class="col-sm-4 col-xs-6">
<div class="panel panel-default">
<div class="panel-thumbnail"><a class="" href="#" title="Renovations"><img src="//placehold.it/600x400/444/F8F8F8" class="img-responsive"></a>
</div>
<div class="panel-body">
<p class="">Renovations</p>
<p class=""></p>
</div>
</div>
<!--/panel-->
</div>
<!--/col-->
<div class="col-sm-4 col-xs-6">
<div class="panel panel-default">
<div class="panel-thumbnail"><a class="" href="#" title="Academic Institutions"><img src="//placehold.it/600x400/454545/FFF" class="img-responsive"></a>
</div>
<div class="panel-body">
<p class="">Academic Institutions</p>
<p class=""></p>
</div>
</div>
<!--/panel-->
</div>
<!--/col-->
<div class="col-sm-4 col-xs-6">
<div class="panel panel-default">
<div class="panel-thumbnail"><a class="" href="#" title="Interiors"><img src="//placehold.it/600x400/555/F2F2F2" class="img-responsive"></a>
</div>
<div class="panel-body">
<p class="">Interiors</p>
<p class=""></p>
</div>
</div>
<!--/panel-->
</div>
<!--/col-->
<div class="col-sm-4 col-xs-6">
<div class="panel panel-default">
<div class="panel-thumbnail"><a class="" href="#" title="New Construction"><img src="//placehold.it/600x400/555/FFF" class="img-responsive"></a>
</div>
<div class="panel-body">
<p class="">New Construction</p>
<p class=""></p>
</div>
</div>
<!--/panel-->
</div>
<!--/col-->
<div class="col-sm-4 col-xs-6">
<div class="panel panel-default">
<div class="panel-thumbnail"><a class="" href="#" title="Site Planning"><img src="//placehold.it/600x400/555/EEE" class="img-responsive"></a>
</div>
<div class="panel-body">
<p class="">Site Planning</p>
<p class=""></p>
</div>
</div>
<!--/panel-->
</div>
<!--/col-->
<div class="col-sm-4 col-xs-6">
<div class="panel panel-default">
<div class="panel-thumbnail"><a class="" href="#" title="Churches"><img src="//placehold.it/600x400/666/F4F4F4" class="img-responsive"></a>
</div>
<div class="panel-body">
<p class="">Churches</p>
<p class=""></p>
</div>
</div>
<!--/panel-->
</div>
<!--/col-->
</div>
<!--/row-->
</div>
<!--/container-->
</pre>
and js script as follow
/* copy loaded thumbnails into carousel */
$('.panel .img-responsive').on('load', function() {
}).each(function(i) {
if(this.complete) {
var item = $('<div class="item"></div>');
var itemDiv = $(this).parent('a');
var title = $(this).parent('a').attr("title");
item.attr("title",title);
$(itemDiv.html()).appendTo(item);
item.appendTo('#modalCarousel .carousel-inner');
if (i==0){ // set first item active
item.addClass('active');
}
}
});
/* activate the carousel */
$('#modalCarousel').carousel({interval:false});
/* change modal title when slide changes */
$('#modalCarousel').on('slid.bs.carousel', function () {
$('.modal-title').html($(this).find('.active').attr("title"));
})
/* when clicking a thumbnail */
$('.panel-thumbnail>a').click(function(e){
e.preventDefault();
var idx = $(this).parents('.panel').parent().index();
var id = parseInt(idx);
$('#myModal').modal('show'); // show the modal
$('#modalCarousel').carousel(id); // slide carousel to selected
return false;
});
So I send image from thumbnail to a modal window with a carousel. What I would like is to add some text to each of the image displayed in the modal.
Thanks for some help.

Categories