How can I get a string from HTML to PHP? - php

Here's my HTML code:
<li>
<a href="#" data-toggle="modal" data-target="#myModal">
<span>Get_Right| $180.000<span>
</a>
</li>
And here's what I need:
When I click the "Get_Right" I want to assign a PHP variable to the name, something like $name = "Get_Right", I have tons of these li's about 50, how can I do it for one so I can replicate it for the other ones aswell?

You can use the following code.
<?php
if(isset($_POST['button1'])){
echo "$180.000";
}
?>
<!--
<li>
<a href="#" data-toggle="modal" data-target="#myModal">
<span>Get_Right| $180.000<span>
<input type="text" name="button1" value="Get Right">
</a>
</li> -->
<form action="resolve.php" method="POST">
<input type="submit" name="button1" value="Get Right">
</form>
I hope that helped you or at least give you a ideea to make.

Related

how to get id value from bootstrap 4 dropdown from table row?

PHP Code:
<td>
<div class="dropdown">
<button class="btn btn-warning dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
More
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton" id="demolist">
<a class="dropdown-item " id="achieve" value="<?php echo $value['user_login_id'] ?>">Achivements</a>
<a class="dropdown-item" id="skill" value="<?php echo $value['user_login_id'] ?>">Skills</a>
<!--
<a class="dropdown-item">Remove</a>
<a class="dropdown-item">View Applicant</a>
-->
</div>
</div>
</td>
Here I have a dropdown button in each row where each dropdown has a list of achievements / skills. When clicking an achievement or skill I want to pass that row's id to ajax.
How should I send with ajax?
Using this method you can easily get the dropdown value:
Pass the id or class by using the .value method.
var submitForm = function() {
var name = document.querySelector('.name').value;
console.log(name);
}
document.querySelector('.btn').addEventListener('click', submitForm);
<input type="text" placeholder="name" class="name"><button class="btn" value="submit">Submit</button>
I have solution like this code i think you enough smart to understand it but let me know if you cant get it.
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton" id="demolist">
<a class="dropdown-item achivementClass" id="achieve" value="value1">Achivements</a>
<a class="dropdown-item" id="skill" >Skills</a>
<a class="dropdown-item">Remove</a>
<a class="dropdown-item">View Applicant</a>
</div>
This your script code
<script>
$(function() {
$('.achivementClass').click(function(){
id =$(this).attr('value');
console.log(id);
});
});
</script>

Unable to post value from bootstrap-wysiwyg text editor in codeigniter

I am using bootstrap-wysiwyg text editor in my form, and I am not able to post value in controller
View :
<form id="demo-form2" action="<?php echo base_url();?>admin/post/add" method="post" enctype="multipart/form-data">
<div class="form-group">
<label for="middle-name" class="control-label col-md-3 col-sm-3 col-xs-12">Post Details<span style="color:red"> <?php echo form_error('details'); ?></span></label>
<div class="col-md-8 col-sm-8 col-xs-12">
<div id="alerts"></div>
<div class="btn-toolbar editor" data-role="editor-toolbar" data-target="#editor">
<div class="btn-group">
<a class="btn dropdown-toggle" data-toggle="dropdown" title="Font"><i class="fa fa-font"></i><b class="caret"></b></a>
<ul class="dropdown-menu">
</ul>
</div>
<div class="btn-group">
<a class="btn dropdown-toggle" data-toggle="dropdown" title="Font Size"><i class="fa fa-text-height"></i> <b class="caret"></b></a>
<ul class="dropdown-menu">
<li>
<a data-edit="fontSize 5">
<p style="font-size:17px">Huge</p>
</a>
</li>
<li>
<a data-edit="fontSize 3">
<p style="font-size:14px">Normal</p>
</a>
</li>
<li>
<a data-edit="fontSize 1">
<p style="font-size:11px">Small</p>
</a>
</li>
</ul>
</div>
</div>
<div id="editor" class="editor-wrapper"></div>
<textarea id="descr" name="descr" style="display:none;"></textarea>
</div>
</div>
<div class="form-group">
<div class="col-md-8 col-sm-8 col-xs-12 col-md-offset-3"> <button type="submit" class="btn btn-success">Submit</button>
</div>
</div>
</form>
And my controller
print_r($_POST); exit;
On searching, I have founded answers like
Solution for this issue
But I don't know how to implement this in my condition. I am getting all the other values expect value in text-area.
Thanks in advance
This will get the editor contents and replace the value of editor_contents on the submit.
<form name="your_form" method="post" onSubmit="document.your_form.editor_contents.value = $('#editor').html()">
<textarea name="editor_contents" style="display:none;"></textarea>
<input type="submit" name="submit">
</form>
And you can access it on PHP like $_POST['editor_contents']
This like passing your data on hidden fields.
Try this
<script type="text/javascript">
$(document).on('submit','#demo-form2',function(){
var editor = CKEDITOR.instances['descr'];
document.getElementById('descr').value = editor.getData();
})
</script>

How to set a <li> as active with php

I'm editing a photography website with a portfolio with links at the top to filter by: View All, Fashion, Family, Weddings, etc.
I'd like to remove "View All" and make "Fashion" (the next list item) set as "active". I'm able to remove the "View All" label by taking it out of the php but it still doesn't set Fashion as active.
I'm using the Miami theme.
I'd appreciate any help!
HTML:
<div id="filters" class="fillter-wrap">
<ul>
<li>
<button class="but activbut active-fillter" data-filter="*">View All</button>
</li>
<li>
<button class="but" data-filter=".fltr-fashion">Fashion</button>
</li>
<li>
<button class="but" data-filter=".fltr-families-couples">Family</button>
</li>
</ul>
PHP:
// filter
if( $filter=='center' ){
$filter_html = "<div id='filters' class='fillter-wrap'>
<ul>
<li>
<button class='but active-fillter' data-filter='*'>View All</button>
</li>
$filter_html
</ul>
</div>";
}
else if( $filter=='toggle' ){
$filter_html = "<div id='filters' class='port5-filters fillter-wrap marg-lg-b15'>
<div class='clearfix show-filter'>
<div class='filter-button'>
<div class='w-embed'>
<i class='fa fa-filter'></i>
</div>
</div>
<div class='filter-effect'>
<span class='filter-txt'>Hide</span><span class='filter-txt-hide'>".esc_html__('Show', 'miami')."</span>
<span class='filter-static'>".esc_html__('Filter', 'miami')."</span>
</div>
</div>
<ul>
<li>
<button class='but active-fillter' data-filter='*'>".esc_html__('', 'miami')."</button>
</li>
$filter_html
</ul>
</div>";
}
else{
$filter_html = "";
}
return "<div class='main-categories n-marg-b30'>
<div class='row'>
$filter_html
<div class='izotope-container col-".abs($columns)." popup-gallery $space'>
<div class='grid-sizer'></div>
$items
</div>
</div>
</div>";
}
Would it be something like this...?
<div id="filters" class="fillter-wrap">
<ul>
<li>
<button class="but activbut active-fillter" data-filter=".fltr-fashion">Fashion</button>
</li>
<li>
<button class="but" data-filter=".fltr-families-couples">Family</button>
</li>
</ul>
Edit: Just realised I may have misunderstood the question. Can you tell us how $filter_html is created? I am not familiar with the miami theme.

Laravel button does not link to route

#extends('layout')
#section('content')
<div class="row">
<div class="col-md-6 col-md-offset-3">
<h1>{{ $id->title }}</h1>
<ul class="list-group">
#foreach($id->notes as $note)
<li class="list-group-item">
{{ $note->body }}
<span class="pull-right">
<button href="/notes/{{ $note->id }}/edit" type="button" class="label label-default pull-xs-right">Edit</button>
</span>
</li>
#endforeach
</ul>
<hr>
<h3>Add a New Note</h3>
<div class="form-group">
<form method="post" action="/cards/{{ $id->id }}/notes">
<div class="form-group">
<textarea name="body" class="form-control"></textarea>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary">Add Note</button>
</div>
</form>
</div>
</div>
</div>
#stop
The button in the foreach loop has the correct link, /note/id/edit. I can type that into chrome and go to the edit page. However, the button does not head there. I just see the click animation. Why would this be?
Button element does not have the href attribute so you can either wrap it in a link tag like this. and this is the easiest way
<a href="{{"/notes/". $note->id. "/edit"}}" >
<button type="button" class="label label-default pull-xs-right">Edit</button
></a>
or you can wrap it in a form element and set the action attribute to your desired link like this.
<Form method="get" action="{{"/notes/". $note->id. "/edit"}}">
<button type="submit" class="label label-default pull-xs-right">Edit</button>
</Form>
the 3rd way is to use javascript and onclick listener.
use <a></a> tag, instead of button, and set type="button"
Check Any

How to send information from CSS-styled button to PHP-script

I am trying to read information from a css-styled web page and send it to a PHP script to be handled. However I can not figure how to do it.
This is the menu button located on the page
<ul class="vmenu">
<li> <span class="l"></span><span class="r"></span><span class="t">Group 1</span> </li>
<li> <span class="l"></span><span class="r"></span><span class="t">Group 2</span> </li>
</ul>...
and this is how I am trying to do it, but it changes it to a visible button and does not fit the styling.
<form name="sidemenu" action="index.php" method="post">
<ul class="vmenu">
<?php while (!empty($categoryname[$categointeger])) { ?>
<li> <input type="submit" name="categoryname" class="button" value="<?php echo"$cateid[$categointeger]"?>"></li>
<?php } ?>
</ul>
</form>
How can I read the information without touching the styling of the page and not using <a href="#">.

Categories