Grabbing Values Outside a Form with PHP - php

I'm using the following code on my site. You'll notice that there is a checkbox outside the form (Towards the bottom). I need the value of the checkbox called to send_mail.php without creating a second form, and without placing it inside the form element. Is this even possible with PHP? `
<h2>Search for your dream home<br />
and save now!</h2>
<legend>Which Areas are you interested in?</legend>
<div class="areas row-fluid" style="text-align:left !important;">
<div class='span5' style='margin-left:0px !important;'>
<label>
<input type="checkbox" name="arrayValue[]" id="area[0]" value="test" style='margin-top:-5px !important;'> test</label>
</div>
</div>
<input type="button" onclick="jQuery('#myModal').modal('show')" value="CONTINUE" />
</div>
</div>
</div>
<!--banner area end-->
<!--content area 1 start-->
<div id="content1">
<div class="content1_in"> <span>
<h2 style="line-height:40px;font-size:40px;padding-bottom:10px">SOME CONTENT
</span>
<div class="img">
<img src="http://f14.co/realtor/assets/images/phone.png" alt="" />
</div>
</div>
</div>
<!--content area 1 end-->
<!--content area 1 start-->
<div id="content2">
<div class="content2_in"> <span> SOME CONTENT
</span>
<div class="img">
<img src="http://f14.co/realtor/assets/images/ipad-img.png" alt="" />
<div class="key"></div>
</div>
</div>
</div>
<!--content area 1 end-->
<!--content area 3 start-->
<div id="content3">
<div class="content3_in"> <span>
SOME CONTENT
</span>
<div class="img">
<img src="http://f14.co/realtor/assets/images/desktop-img.png" alt="" />
</div>
<div class="free"></div>
</div>
</div>
<!--content area 3 end-->
<div id="footer">
<div class="footer_in">
This Website Is Brought To You By: Test</div>
</div>
<!-- Modal -->
<div id="myModal" class="modal hide fade modal-survey" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel" class="survey_title">What type of home are you looking for?</h3>
</div>
<form method="post" class="form-horizontal" id="final_form" action="send_mail.php">
<input type="hidden" name="template" id="template" value="Buyers" />
<div class="modal-body" >
<div id="lead_info_1">
<div class="input select">
<div class=""></div>...

I would add a hidden input in your form.
Then, just before your post, assign the of the hidden textbox with the value of the checkbox.
(using jQuery)

Related

Can't open Bootstrap modal in codeigniter

I can't open my modal in CodeIgniter.
I did a view for the modal and then I loaded in the controller. But when I click on the button, it doesn't show anything. No response. head have the Jquery and Bootstrap imports in the correct order.
Here i show you my code:
cdashboard.php:
//header
$this->load->view('UI/vheader');
//sidebar
$this->load->view('UI/vsidebar',$data);
//modals
$data['modaltarea'] = $this->load->view('tareas/vmodalnewtarea',NULL,TRUE);
//data in dashboard
$this->load->view('vdashboard',$data);
//footer
$this->load->view('UI/vfooter');
vmodalnewtarea.php:
<div id="newTareaModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="newTarea" aria-hidden="true">
<div class="modal-dialog" >
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Tarea nueva</h5>
</div>
<div class="modal-body">
<div class="container-fluid">
<!--Importar plantilla-->
<div class="row">
<div class="col-md-12">
<h3>Importar plantilla</h3>
</div>
<div class="row">
<!--Proyecto-->
<div class="col-md-4">
</div>
<!--Fase-->
<div class="col-md-4">
</div>
<!--Tarea-->
<div class="col-md-4">
</div>
</div>
</div>
<!--Nueva Fase-->
<div class="row">
<div class="col-md-12">
<h3>Nueva Tarea</h3>
</div>
<div class="row">
<div class="col-md-4">
<div class="row">
<input type="text" placeholder="Nombre" required />
</div>
<div class="row">
<!--<table id="tableHitos" class="table table-bordered table-strip" >
<thead>
<th>
Hitos
</th>
</thead>
<tbody>
</tbody>
</table>-->
<a type="button" class="btn"><i class="fa fa-plus"></i></a>
</div>
</div>
<div class="col-md-8">
<textarea id="txtaTarea" rows="5" placeholder="Descripcion" required>
</textarea>
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<p>
aaaaaa
</p>
</div>
</div>
</div>
</div>
And the view where I call the modal, on other view (vrowfase.php):
<div class="row fase">
<div class="col-lg-12">
<div class="col-lg-2 text-center">
<div class="callout callout-warning">
<h4><?= $fase->nombre?></h4>
<div class="progress progress-xxs">
<div class="progress-bar" role="progressbar" style="width: 50%">
</div>
</div>
</div>
</div>
<div class="projectBar col-lg-10">
<div class="row Bar">
<?= $tareas; ?>
<button type="button" class="btn btn-app text-center" data-toogle="modal" data-target="#newTareaModal">
<i class="fa fa-plus"></i>
Nueva Tarea
</button>
</div>
</div>
</div>
</div>
thanks for the help!
your modal id is
newTareaModal
and your data-target in button is
TareaModal
was a error writing.
on vrowfase.php I had "data-toogle" and is "data-toggle"
thank you anyway!

How to display content from PHP to html

So what i'am trying to do is that I have a PHP page that gets the ID for some text stored in a database (Varchar) and I wish to display this content in my HTML page. So I can update the content in the database and the edit take effect across the site.
PHP:
$id = $_GET['id'];
// do some validation here to ensure id is safe
$link = mysql_connect("localhost", "root", "");
mysql_select_db("images");
$sql = "SELECT review FROM reviews WHERE id=$id";
$result = mysql_query("$sql");
$row = mysql_fetch_assoc($result);
mysql_close($link);
echo $row['review'];
I wish to display the content where is says "PHP content here"
HTML:
<div class="modal fade" id="albumModal1">
<div class="modal-dialog">
<div class="modal-content">
<!-- Top right close X -->
<div class="close-modal" data-dismiss="modal">
<span class="glyphicon glyphicon-remove"</span>
</div>
<div class="container">
<div class="row">
<div class="col-lg-8 col-lg-offset-2">
<div class="modal-body">
<p class="modalTitle">The Beatles: Abby Road</p>
<img src="beatles.jpg" class="img-responsive center-block albumImgGrey">
<!-- Album 1's Review -->
<div class="modalText">
<p>Content upon content upon more content
<p>upon more content</p>
Content upon content upon more content
<p>upon more content</p>
<div class="starcolor">
<span>&#9733 &#9733 &#9733 &#9733 &#9733</span>
</div>
</p>
<!-- PHP content here....... -->
<!-- PHP content here....... -->
<!-- Bottom of the review links -->
<ul class="list-inline item-details">
<li>
Year of release: <strong>3000</strong>
</li>
<li>
Previous Album: <strong>Hippie tree</strong>
</li>
<li>
Following Album: <strong>Backup Plus++</strong>
</li>
</ul>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Any help or advice would be greatly appreciated.
Add this code:
<?php echo $row['review'];?>
where you have PHP content here, ensure you include the PHP tags.
STOP USING THE MYSQL EXTENSION, A KITTEN AND TWO PUPPIES DIE ANYTIME YOU DO THIS
Learn pdo or mysqli instead.
You can put your database result in a php file and then Web server will parse that php code and generate the required output.
It should be like.
output.php
<?php
<div class="modal fade" id="albumModal1">
<div class="modal-dialog">
<div class="modal-content">
<!-- Top right close X -->
<div class="close-modal" data-dismiss="modal">
<span class="glyphicon glyphicon-remove"</span>
</div>
<div class="container">
<div class="row">
<div class="col-lg-8 col-lg-offset-2">
<div class="modal-body">
<p class="modalTitle">The Beatles: Abby Road</p>
<img src="beatles.jpg" class="img-responsive center-block albumImgGrey">
<!-- Album 1's Review -->
<div class="modalText">
<p>Content upon content upon more content
<p>upon more content</p>
Content upon content upon more content
<p>upon more content</p>
<div class="starcolor">
<span>&#9733 &#9733 &#9733 &#9733 &#9733</span>
</div>
</p>
<!-- PHP content here....... -->
$id = $_GET['id'];
$link = mysql_connect("localhost", "root", "");
mysql_select_db("images");
$sql = "SELECT review FROM reviews WHERE id=$id";
$result = mysql_query("$sql");
$row = mysql_fetch_assoc($result);
mysql_close($link);
echo $row['review'];
<!-- PHP content here....... -->
<!-- Bottom of the review links -->
<ul class="list-inline item-details">
<li>
Year of release: <strong>3000</strong>
</li>
<li>
Previous Album: <strong>Hippie tree</strong>
</li>
<li>
Following Album: <strong>Backup Plus++</strong>
</li>
</ul>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
?>
<div class="modal-dialog"> <div class="modal-content"> <!-- Top right close X --> <div class="close-modal" data-dismiss="modal"> <span class="glyphicon glyphicon-remove"</span> </div> <div class="container"> <div class="row"> <div class="col-lg-8 col-lg-offset-2"> <div class="modal-body"> <p class="modalTitle">The Beatles: Abby Road</p> <img src="beatles.jpg" class="img-responsive center-block albumImgGrey"> <!-- Album 1's Review --> <div class="modalText"> <p>Content upon content upon more content <p>upon more content</p> Content upon content upon more content <p>upon more content</p> <div class="starcolor"> <span>&#9733 &#9733 &#9733 &#9733 &#9733</span> </div> </p> <!-- PHP content here....... --> <!-- PHP content
<?php echo $row['content']; ?>
here....... --> <!-- Bottom of the review links --> <ul class="list-inline item-details"> <li> Year of release: <strong>3000</strong> </li> <li> Previous Album: <strong>Hippie tree</strong> </li> <li> Following Album: <strong>Backup Plus++</strong> </li> </ul> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> </div> </div> </div> </div> </div> </div> </div> </div>

How to remember what user user was clicked?

How to write a code which will remember when user click on picture "Vlado.jpg" and continue on form "forma_id"?
I need this information becouse when user submite form i will use this in my php.script in if block.
<html>
<div class="tab-pane fade Osiguranje_id">
<div class="container cont_osiguranje">
<div class="jumbotron jumb_osiguranje">
<a id="Osiguranje_id"><h2>Odaberi zastupnika</h2></a>
</div>
<div class="jumbotron">
<div class = "row">
<div class = "col-md-6 col-sm-6 col-xs-12">
<a data-toggle="pill" href="#forma_id"><img src="Vlado.jpg" class="img-rounded img-responsive" name="vlado"></a>
</div>
</div>
</div>
</div>
</div>
</br></br></br></br></br></br></br></br></br></br></br></br></br></br></br></br>
<div id="forma_id" class="tab-pane fade">
<div class="container cont_forma">
<div class="jumbotron jumb_forma">
<a id="forma_id"><h2>Ispunite formu:</h2></a></br>
<form class="form-horizontal" role="form" action="proba4.php" method="POST">
<div class="form-group">
<label class="control-label col-sm-2" for="ime">Ime:</label>
<div class="col-sm-4"><input type="text" required class="form-control" name="ime" placeholder="Ime"></div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-4"><input type="submit" name="submit" value="Pošalji"/></div>
</div>
</form>
</div>
</div>
</div>
</html>
You'll most likely want to create a hidden input in your form, and by default it's false, or has some other value (that means didn't click the img - for your situation), when the user clicks the image, use Javascript to change this hidden input value to true (or to a value that means they did click the img - for your situation).

Creating a custom Woocommerce product modal on click

I have created a basic HTML/jQuery structure for a modal that will pop up when clicked on. I'm in the process of integrating Woocommerce into my site and am unsure as to how I can do the following:
Have modal load respective product info
Integrate into a Woocommerce loop
Here is my HTML for the skeleton of what I'm trying to achieve:
<div class="col-md-4"><img src="<?php bloginfo('stylesheet_directory'); ?>/media/temp_product_images/Alto-183x300.jpg" alt="Product Img" class="product-img" data-toggle="modal" data-target="#myModal">
<p class="product-img-title text-center">Alto</p>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title text-center" id="myModalLabel">Alto</h4> </div>
<div class="modal-body" id="modal-body-one">
<div class="row">
<div class="col-sm-4"> <img src="<?php bloginfo('stylesheet_directory'); ?>/media/temp_product_images/Alto-183x300.jpg" alt="Modal Product Img" id="product-img"> </div>
<div class="col-sm-7">
<h5>Colours</h5>
<div class="scroll-container">
<div class="row">
<div class="col-xs-4">
<div class="selected-product-color"><img src="<?php bloginfo('stylesheet_directory'); ?>/media/temp_product_images/MACASSA.jpg" alt="Product Colour">
<p>Macassa</p>
</div>
</div>
</div>
<!-- End of Test Case -->
</div>
</div>
<div class="col-sm-1">
<button type="button" class="btn flip"><i class="fa fa-arrow-right" aria-hidden="true"></i></button>
</div>
</div>
</div>
<!-- Prices -->
<div class="modal-body" id="modal-body-two">
<div class="row">
<div class="col-sm-11">
<div class="row">
<h5 id="modal-prices">Download Price List</h5></div>
<div class="row">
<?php $my_query = new WP_Query('p=47');
while($my_query->have_posts()){
$my_query->the_post();
the_content();
} ?>
</div>
</div>
<div class="col-sm-1">
<button type="button" class="btn flip"><i class="fa fa-arrow-right" aria-hidden="true"></i></button>
</div>
</div>
</div>
<div class="modal-footer"> Get Quote </div>
</div>
</div>
</div>
<!-- End of Modal -->
</div>
And here is my jQuery:
//Modal Change Content
$('#modal-body-two').hide();
$('.flip').on('click', function () {
$('#modal-body-one, #modal-body-two').toggle()
});
Is there a way that I can display the product info on click within a modal using Woocommerce? Thanks

Dynamic php modal

I'm trying create modal that is dynamic and pre fills with the details of the item that is clicked on. Here is my code:
HTML:
{foreach from=$flowers3 item=row}
{foreach from=$row item=item}
<div class="item col-lg-4 col-md-4 col-sm-4 col-xs-12">
<div class="product">
<div class="image">
<div class="quickview">
<a alt="Quick View" class="btn btn-xs btn-quickview" data-target="#modal" data-toggle="modal"> View </a>
</div>
<a href="#">
<img class="item_thumb img-responsive" src="img/{$item.im}" alt="img">
</a>
</div>
<div class="description">
<h4 class="item_name">{$item.title}</h4>
<p class="item_price">
small
<input type="Radio" name="product" value="{$item.id}s" style="border:0;cursor:pointer;" />
<span style="font-weight: bold">${$item.ps|money:0}</span> | med
<input type="Radio" name="product" value="{$item.id}m" style="border:0;cursor:pointer;" />
<span style="font-weight: bold">${$item.pm|money:0}</span> | lg
<input type="Radio" name="product" value="{$item.id}l" style="border:0;cursor:pointer;" />
<span style="font-weight: bold">${$item.pl|money:0}</span>
</p>
</div>
<div class="action-control">
<a href="javascript:;" onClick="mySubmit()">
<span class="button-fill grey">
<i class="glyphicon glyphicon-shopping-cart">
</i> Add to cart </span>
</a>
</div>
</div>
</div>
{/foreach}
{/foreach}
Here's the PHP:
<?php
$GLOBALS['flowers']=getFlowers();
function &getFlowers(){
static $flowers;
if(!isset($flowers)){
$flowers=array(
'1'=>array('im'=>'store-a1.jpg','title'=>'CocoChanel','description'=>' Fashion fades.'),
'2'=>array('im'=>'store-a2.jpg','title'=>'The Royal Jewels','description'=>'Fit for any Queen.'),);}
$i=1;
foreach($flowers as $k=>&$v){
$v['id']=$k;
$v['num']=$i++;}
return $flowers;}
?>
And here's the modal:
<!--modal -->
<div class="modal fade" id="modal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<button aria-hidden="true" data-dismiss="modal" class="close" type="button"> ×</button>
<div class="col-lg-5 col-md-5 col-sm-5 col-xs-12">
<!-- product Image -->
<div class="main-image col-lg-12 no-padding style3 modal-image">
<a class="product-largeimg-link" href="#">
<img src="img/{$item.imb}" class="img-responsive product-largeimg" alt="img">
</a>
</div>
<!--/image-->
</div>
</div>
<!--/ product Image-->
<div class="col-lg-7 col-md-7 col-sm-7 col-xs-12 modal-details no-padding">
<div class="modal-details-inner">
<h1 class="product-title">{$item.title}</h1>
<div class="details-description">
<p>{$item.description}</p>
</div>
<div class="clear"></div>
</div>
</div>
</div>
</div>
<!--/modal -->
When I add the modal within the {foreach} tags, it only fills with the information for one particular item (depending on where I place it. ex: it might be the first item, or if I place it between the {foreach from=$flowers3 item=row} it will be the last of the first row) but I can't get it to update every item on the particular "Quick View" that is clicked.
Thanks in advance for any help!!
Store the properties of the items in data-attributes of the item 's in your html:
<div class="item ..." ... data-title="Nice flower" data-price="€1,20" > ... </div>
Now use some javascript to update the modal. jQuery example:
$('.item').click(function(){
var el = $(this);
$('.modal .product-title').text(el.attr('data-title'));
// and the rest of the properties, then open the modal
});

Categories