How to include virtual keyboard(numeric pad) in website? - php

There is a form filling in my website, and i included virtual keyboard there, when user click in textarea, then virtual keyboard will appear, and in some forms user needs to fill numbers, so i want to include numeric pad in forms where should fill the numbers. I found one, but i cant include it.
I included scripts and css in my tpl file, first 3 of numpad, the rest of keyboard:
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery.keypad.js"></script>
<link type="text/css" href="jquery.keypad.css" rel="stylesheet">
<script type="text/javascript" src="keyboard.user.js" charset="UTF-8"></script>
<link rel="stylesheet" type="text/css" href="keyboard.css">
<main class="main" style="padding:0; overflow-x:initial">
<div class="container">
{include file="engine/modules/products/eogpo.php"}
</div>
</main>
<div id="isTerminal"></div>
$(function () {
$('#defaultKeypad').keypad();
});
<div id="modalError" class="modal info__modal" data-modal>
<button data-izimodal-close="" class="modal__close">
<svg class="icon icon-close"><use xlink:href="/images/sprite.svg#icon-close"></use></svg>
</button>
<div class="modalStyle">
<h3 class="info__title" id="errorTitle"><?php echo _("Ошибка"); ?></h3>
<div id="textError"></div>
</div>
</div>
<div id="modalInfo" class="modal info__modal" data-modal>
<button data-izimodal-close="" class="modal__close">
<svg class="icon icon-close"><use xlink:href="/images/sprite.svg#icon-close"></use></svg>
</button>
<div class="modalStyle">
<div id="textInfo"></div>
</div>
</div>
<div id="overLoader" style="display: none"><img src="/templates/assets/images/loading.gif" alt="Loading..." /></div>
In tutorial written that I should write:
$(function () {
$('#defaultKeypad').keypad();
});
to call the plugin with default options, so i wrote it in tpl file
so finally i include the numpad id in:
<fieldset class="field-set col col--4-12" style="false">
<label for="orderIIN" class="field-set__label checkList">
<?php echo _("IIN");?>
</label>
<input class=" field iin-masked datas" id="IIN0 defaultKeypad" type="text" name="IIN[]" maxlength="12" />
<span class="small col" id="textKBM0"></span>
<span class="small col" id="loadingIIN0"></span>
<input class="datas" id="KBM0" type="hidden" name="KBM[]" value="" />
<input class="datas" id="clientID0" type="hidden" name="clientID[]" value="" />
<input class="datas" id="clientISN0" type="hidden" name="clientISN[]" value="" />
<input class="datas" id="clientNation0" type="hidden" name="clientNation[]" value="Kazakhstan" />
</fieldset>
Keyboard js works fine, but numpad js still doesn't turn on, where am i doing wrong?

You are probably missing jquery-ui assets
STEP 1 - INCLUDE JQUERY
Append the below script tag on top of your page and delete the previous jquery script tags.
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
open the page with chrome, open the developer tools by pressing f12 and make sure that you have the following files under Sources tab:
jquery.min.js
jquery-ui.min.js
jquery-ui.css
STEP 2 - INCLUDE JQUERY KEYPAD CSS AND JS
Download jquery.keypad.css, jquery.plugin.js and jquery.keypad.js from here
Unzip the file jquery.keypad.package-2.2.1 and move them to the respective js and css folder of your project.
Add on top of your page, after the jquery script tag the following script.
<link type="text/css" href="css/jquery.keypad.css" rel="stylesheet">
<script type="text/javascript" src="js/jquery.plugin.js"></script>
<script type="text/javascript" src="js/jquery.keypad.js"></script>
As explained above, refresh and verify that the assets are included in your application
STEP 3 - INCLUDE JQUERY KEYPAD CSS AND JS
Open your chrome developer console to run the following commands:
$(selector).keypad();
where selector is replaced from the #id or .class of your div. In your case should be:
$('#defaultKeypad').keypad();
I selected a div from the page as in the below picture
[
then I run .keypad() and the .keypad() show in the page
you can find all the instruction and you can also test the functionality on this page

I don't know about the JQ version but I just made this one up.
Each textbox will have it own id and onclick event:
showKeyPad(x, y, this.id):
x = margin-left
y = margin-top
You can set x and y to null to ignore.
Even if it is not what you would like, I enjoyed making it and anyone is welcome to improve it in anyway. Totally free without ads :)
Copy Paste the following to give it a trial.
<html>
<head>
<style>
#keypad{
position: absolute;
background-color: lightblue;
margin-left: 20vw;
margin-top: 20vh;
width: 14vw;
height: 30vh;
border-color: grey;
border-width: 1px;
border-style: solid;
border-radius: 2%;
}
.keypads{
display: inline;
width: 28%;
height: 19%;
margin-top: 5%;
margin-left: 3%;
border-color: grey;
border-width: 1px;
border-style: solid;
border-radius: 2%;
}
</style>
<script type="text/javascript">
var focused;
function showKeypad(x, y, tBox){
var keypad = document.getElementById("keypad");
if(x != null && y != null){
keypad.style.marginLeft = x + "vw"; //Setting x and y are optional but it can be
keypad.style.marginTop = y + "vh"; // set to render near textboxes // Set x & y to 0 to ignore
}
keypad.style.display = "block";
window.focused = document.getElementById(tBox);
}
function hideKeyPad(){
var keypad = document.getElementById("keypad");
keypad.style.display = "none";
}
function SendInputs(input){
if(focused){
if(input != "CE"){
var oldText = focused.value;
oldText += input;
focused.value = oldText;
}else
{
focused.value = "";
}
}else hideKeyPad();
}
</script>
</head>
<body>
<div id="keypad" style="display: none;">
<input type="button" class="keypads" value="1" onclick="SendInputs('1')">
<input type="button" class="keypads" value="2" onclick="SendInputs('2')">
<input type="button" class="keypads" value="3" onclick="SendInputs('3')"><br>
<input type="button" class="keypads" value="4" onclick="SendInputs('4')">
<input type="button" class="keypads" value="5" onclick="SendInputs('5')">
<input type="button" class="keypads" value="6" onclick="SendInputs('6')"><br>
<input type="button" class="keypads" value="7" onclick="SendInputs('7')">
<input type="button" class="keypads" value="8" onclick="SendInputs('8')">
<input type="button" class="keypads" value="9" onclick="SendInputs('9')"><br>
<input type="button" class="keypads" value="CE" style="color:red;" onclick="SendInputs('CE')">
<input type="button" class="keypads" value="0" onclick="SendInputs('0')">
<input type="button" class="keypads" value="X" style="color:red;" onclick="hideKeyPad()">
</div>
<div>
<input id="Phone" type="text" onclick="showKeypad(5, 10, this.id)">
<input type="text" >
<input type="text" >
<input type="text" >
<input id="ID" type="text" onclick="showKeypad(50, 10, this.id)">
<input type="text" >
<input type="text" >
<input id="DOB" type="text" onclick="showKeypad(80, 10, this.id)">
</div>
</body>
</html>

Related

I need help making the submit button only appear when you have typed in the text box

I'm using html and I have a text box and I also have the submit button but I only want the button to appear when you have typed text into the text box. I also have a lot of php in my scripts you its fine if you do it with that.
I've tried different on click events and I've searched everywhere but i can't find anything. I know this is probably a simple question but I'm completely stuck.
<div class = "profileLeftSideContent">
<form action="<?php echo $username; ?>" method="post">
<textarea id="post" name="post" rows="15" cols="40" placeholder="Bio goes
here...">
</textarea>
<input id="buddon" type="submit" name="send"
value="Save" style="background-color: #DCE5EE; border: 3px solid #666;
color:#666; height: 65px; width: 73px;">
</form>
</div>
I want the button named save to only appear when you have typed in the above text area. (note, there is more code than this and the text box and button show up fine normally)
It is pretty simple:
function ckField(){
if($.trim($('#post').val()) == ""){
$('#buddon').css('display', 'none');
}else{
$('#buddon').css('display', '');
}
}
$('#post').keyup(function(){ ckField(); });
//initial state
ckField();
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class = "profileLeftSideContent">
<form action="<?php echo $username; ?>" method="post">
<textarea id="post" name="post" rows="5" cols="40" placeholder="Bio goes
here...">
</textarea>
<input id="buddon" type="submit" name="send"
value="Save" style="background-color: #DCE5EE; border: 3px solid #666;
color:#666; height: 65px; width: 73px;">
</form>
</div>
I reduced the textara rows to 5, for display reasons.

Wordpress basic plugin backend on running?

I have built a basic contact from that has multiple divs, after testing this on my localhost without CMS it seems to work, but when i create a wordpress plugin and call the form via shortcode the post does not show any sign of being filled.
function pagechange(frompage, topage) {
var page=document.getElementById('formpage_'+frompage);
if (!page) return false;
page.style.visibility='hidden';
page.style.display='none';
page=document.getElementById('formpage_'+topage);
if (!page) return false;
page.style.display='block';
page.style.visibility='visible';
return true;
}
<form action="" method="post">
<div id="formpage_1" style="visibility: visible; display: block;">
<h1>We would Love to Hear about your Project!</h1>
<p>Please answer a few questions, this will save time on communication and help you receive an answer quickly.</p>
<?php if(isset($_POST['cf-submitted'])) {
$name = $_POST['name-form'];
echo $name;
} ?>
<input class="button1-form" type="button" value="next" onclick="pagechange(1,2);" />
</div>
<div id="formpage_2" style="visibility: hidden; display: none;">
<h4>What is your name?</h4>
<input type="text" name="name-form" />
<input class="next-btn-form" type="button" value="next" onclick="pagechange(2,3);" />
</div>
<div id="formpage_3" style="visibility: hidden; display: none;">
<h4>Hello! Tell us your Company Name?</h4><?php echo $name; ?>
<input type="text" name="companyname" />
<input class="next-btn-form" type="button" value="next" onclick="pagechange(3,4);" />
</div>
<div id="formpage_4" style="visibility: hidden; display: none;">
<h4>Tell us a bit about your Project?</h4>
<input type="text" name="project" />
<input class="next-btn-form" type="button" value="next" onclick="pagechange(4,5);" />
</div>
<div id="formpage_5" style="visibility: hidden; display: none;">
<h4>What is your email so we can contact you?</h4>
<input type="email" name="email" />
<input class="next-btn-form" type="submit" value="next" onclick="pagechange(5,1);" />
</div>
I just tested it on the jsfiddle, doesnt seem to be working either now, am i missing something here?
Im still learning so i am not the best XD
Alex

Why does my form keep repeating? It seems like the php isn't running

I have a file called form.php and when I upload it to my server, that supports php, the form keeps on repeating and never executes the php code. I uploaded it at http://davidjahn.info/DavidJahnNet/form.php
<?php
$age=$_POST["age"];
echo $age;
?>
<html>
<head>
<title>Survey</title>
<style type="text/css">
.welcome {
color: #FFFFFF;
text-align: center;
background-color:red;
font-weight:bold;
height: 50px;
}
</style>
</head>
<body>
<table style="height: 232px; width: 500px">
<form method="post" id="survey" action="form.php">
<tr>
<td>
<div class="welcome"><br>Welcome!</div>
</td>
</tr>
<tr>
<td>
<ul>
<br>
<br>
<div id="question1" style="display: inline;">
<h3>
Are You 30+ Years Old?
</h3>
<div style="height: 10px"></div>
<input type="button" name="age" value="Yes" onclick="document.getElementById('question1').style.display='none';document.getElementById('question2').style.display='inline';">
<input type="button" name="age" value="No" onclick="document.getElementById('question1').style.display='none';document.getElementById('question2').style.display='inline';">
</div>
<div id="question2" style="display: none;">
<h3>
Are You Looking for a Date?
</h3>
<div style="height: 10px"></div>
<input type="button" name="date" value="Yes" onclick="document.getElementById('question2').style.display='none';document.getElementById('question3').style.display='inline';">
<input type="button" name="date" value="No" onclick="document.getElementById('question2').style.display='none';document.getElementById('question3').style.display='inline';">
</div>
<div id="question3" style="display: none;">
<h3>
Which Girl Is Your Type?
</h3>
<div style="height: 10px"></div>
<input type="image" src="http://healthystartups.com/storage/600px-MA_Route_1.png?__SQUARESPACE_CACHEVERSION=1319542839834" alt="Submit" width="100px" value="type1" />
<input type="image" src="http://jenntgrace.com/wp-content/uploads/2012/12/2.png" alt="Submit" width="100px" value="type2" />
<input type="image" src="http://3.bp.blogspot.com/-Q_owQUxNjdQ/Te3ALCmT3oI/AAAAAAAAAnk/wv9r0b0MT-g/s1600/600px-MA_Route_3.svg_.jpg" alt="Submit" width="100px" value="type3" />
<input type="image" src="http://4.bp.blogspot.com/-wY_qFr2pcAs/UCxhAayJ6oI/AAAAAAAAC6w/PgtLs2O_4g8/s1600/4.png" alt="Submit" width="100px" value="type4" />
</div>
</ul>
</td>
</tr>
</form>
</table>
</body>
</html>
PHP is a server-side language. You need a server running PHP to write PHP pages. You can't simply save them and open them in your browser.
Look into something like XAMPP which will get you up-and-running quickly with a development environment.
Are you testing this on localhost ? I think you don't have WAMP installed and you are trying to view .php file without php server & you must know that php is server side language. Install EasyPHP and then you will be able to run .php
http://www.easyphp.org/
You should use buttons for submitting. I have edited your code to do the following:
buttons that have cover images of the four types
hidden values to represent age, date
Code:
<?php
if (isset($_POST['age'])) {
$age=$_POST["age"];
echo $age;
}
?>
<html>
<head>
<title>Survey</title>
<style type="text/css">
.welcome {
color: #FFFFFF;
text-align: center;
background-color:red;
font-weight:bold;
height: 50px;
}
.type1 {
background-image: url(http://healthystartups.com/storage/600px-MA_Route_1.png?__SQUARESPACE_CACHEVERSION=1319542839834);
}
.type2 {
background-image: url(http://jenntgrace.com/wp-content/uploads/2012/12/2.png);
}
.type3 {
background-image: url(http://3.bp.blogspot.com/-Q_owQUxNjdQ/Te3ALCmT3oI/AAAAAAAAAnk/wv9r0b0MT-g/s1600/600px-MA_Route_3.svg_.jpg);
}
.type4 {
background-image: url(http://4.bp.blogspot.com/-wY_qFr2pcAs/UCxhAayJ6oI/AAAAAAAAC6w/PgtLs2O_4g8/s1600/4.png);
}
input[type=submit]{
border: none;
width: 100px;
height: 100px;
background-size:cover;
}
</style>
</head>
<body>
<table style="height: 232px; width: 500px">
<form method="post" id="survey" action="form.php">
<input type="hidden" name="age" id="age">
<input type="hidden" name="date" id="date">
<tr>
<td>
<div class="welcome"><br>Welcome!</div>
</td>
</tr>
<tr>
<td>
<ul>
<br>
<br>
<div id="question1" style="display: inline;">
<h3>
Are You 30+ Years Old?
</h3>
<div style="height: 10px"></div>
<input type="button" value="Yes" onclick="document.getElementById('question1').style.display='none';document.getElementById('question2').style.display='inline';document.getElementById('age').value='Yes'">
<input type="button" value="No" onclick="document.getElementById('question1').style.display='none';document.getElementById('question2').style.display='inline';document.getElementById('age').value='No'">
</div>
<div id="question2" style="display: none;">
<h3>
Are You Looking for a Date?
</h3>
<div style="height: 10px"></div>
<input type="button" value="Yes" onclick="document.getElementById('question2').style.display='none';document.getElementById('question3').style.display='inline';document.getElementById('date').value='Yes'">
<input type="button" name="date" value="No" onclick="document.getElementById('question2').style.display='none';document.getElementById('question3').style.display='inline';document.getElementById('date').value='No'">
</div>
<div id="question3" style="display: none;">
<h3>
Which Girl Is Your Type?
</h3>
<div style="height: 10px"></div>
<input type="submit" value="1" class="type1" name="type" />
<input type="submit" value="2" class="type2" name="type" />
<input type="submit" value="3" class="type3" name="type" />
<input type="submit" value="4" class="type4" name="type" />
</div>
</ul>
</td>
</tr>
</form>
</table>
</body>
</html>
Make sure you are running your code on a localhost server because PHP only works on server side not client side.
If you are running it correctly use this for better practice:
if(isset($_POST['age'])){
$age=$_POST["age"];
echo $age;
}
Your Javascript and HTML doesn't make much sense if you are looking for the age field.
The age elements that you have are two buttons.
You could solve this by using <input type="hidden" name="age" value=""> and then modifying the value of this using Javascript, when the user clicks your buttons (if you do this, change the name attribute of your buttons).
OR you could solve it by replacing the buttons with radio buttons.
Simply replace <input type="button" name="age" ...
with <input type="radio" name="age" ...>
I'm not sure what you're trying to say. Could you elaborate a bit more?
On the other hand, by taking a rough guess, it could be your browser. Try add
<!DOCTYPE html>
above
<html>
EDIT: If you're talking about PHP printing rather than doing what it's meant to do. Well just to let you know, PHP is a server side scripting language. It needs to be processed via PHP engine. Are you on a shared web host or did you setup your own server?

HTML form not submitting values

This is my form and it is not passing any values.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<style type="text/css">
.welcome {
color: #FFFFFF;
text-align: center;
background-color:red;
font-weight:bold;
height: 50px;
}
</style>
<script type="text/javascript">
function submitimg(myvalue)
{
document.getElementById('type').value = myvalue;
document.getElementById('survey').submit();
}
</script>
</head>
<body>
<table style="height: 232px; width: 500px">
<form action="" method="post" name="survey" id="survey">
<tr>
<td>
<div class="welcome"><br>Welcome!</div>
</td>
</tr>
<tr>
<td>
<ul>
<br>
<br>
<div id="question1" style="display: inline;">
<h3>
Are You 30+ Years Old?
</h3>
<div style="height: 10px"> </div>
<input type="button" name="age30" value="Yes" onclick="document.getElementById('question1').style.display='none';document.getElementById('question2').style.display='inline';">
<input type="button" name="age30" value="No" onclick="document.getElementById('question1').style.display='none';document.getElementById('question2').style.display='inline';">
</div>
<div id="question2" style="display: none;">
<h3>
Are You Looking for a Date?
</h3>
<div style="height: 10px"> </div>
<input type="button" name="date" value="Yes" onclick="document.getElementById('question2').style.display='none';document.getElementById('question3').style.display='inline';">
<input type="button" name="date" value="No" onclick="document.getElementById('question2').style.display='none';document.getElementById('question3').style.display='inline';">
</div>
<div id="question3" style="display: none;">
<h3>
Which Girl Is Your Type?
</h3>
<div style="height: 10px"> </div>
<input type="hidden" name="type" value="">
<img src="http://healthystartups.com/storage/600px-MA_Route_1.png?__SQUARESPACE_CACHEVERSION=1319542839834" width="100px" style="cursor:pointer;" onclick="submitimg('type1');">
<img src="http://jenntgrace.com/wp-content/uploads/2012/12/2.png" width="100px" style="cursor:pointer;" onclick="submitimg('type2');">
<img src="http://3.bp.blogspot.com/-Q_owQUxNjdQ/Te3ALCmT3oI/AAAAAAAAAnk/wv9r0b0MT-g/s1600/600px-MA_Route_3.svg_.jpg" width="100px" style="cursor:pointer;" onclick="submitimg('type3');">
<img src="http://4.bp.blogspot.com/-wY_qFr2pcAs/UCxhAayJ6oI/AAAAAAAAC6w/PgtLs2O_4g8/s1600/4.png" width="100px" style="cursor:pointer;" onclick="submitimg('type4');">
</div>
</ul>
</td>
</tr>
</form>
</table>
<?php
$age30 = $_POST['age30'];
$date = $_POST['date'];
$type = $_POST['type'];
echo $_POST['age30'];
?>
</body>
</html>
There is error in your html. Names should be unique. In your case it's better to use radio than button.
<input type="radio" name="age30" value="yes">
<input type="radio" name="age30" value="No" >
echo $_POST['age30'];
Test this code.
Also change your submiting function to this(Jquery Example)
$(function(){
$(".submit_img").click(function (){
$("#survey").submit(); // this line will submit form
});
});
now when you add to element 'submit_img' class, then if someone click this element the form with id=survey will be submitted.
<img src="http://jenntgrace.com/wp-content/uploads/2012/12/2.png" width="100px" style="cursor:pointer;" class="submit_img">
DEMO
Try rename inputs like this
<input type="button" name="date[]" value="Yes">
<input type="button" name="date[]" value="No">
Please specify an action for your form. Create another php file to get the POST variables and put that name inside action.

Populating Many checkboxes in tree structure inside Dropdown

Guys Here is the checkboxes, where it displays in tree structure. I need it to be displayed inside the dropdown.
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('.team').on('click',function(){
if($(this).is(':checked')){
$(this).next().next().show();
}else{
$(this).next().next().hide();
}
});
});
</script>
</head>
<body>
<form name="FootballClubs">
<input type="checkbox" class="team" value="RealMadrid"/>Real Madrid<br />
<div style="padding:10px 10px 10px 15px;display:none;">
<input type="checkbox" class="player" value="CR"/>Cristiano Ronaldo<br />
<input type="checkbox" class="player" value="SA"/>Shabi Alanso<br />
<input type="checkbox" class="player" value="IC"/>Iker Casillias<br />
</div>
<input type="checkbox" class="team" value="ManCity"/>Man City<br />
<div style="padding:10px 10px 10px 15px;display:none;">
<input type="checkbox" class="player" value="SA"/>Sergio Aguero<br />
<input type="checkbox" class="player" value="SM"/>Super Mario<br />
</div>
</form>
</body>
</html>
I am trying to populate inside a dropdown. Help me.
Thanks in Advance.!!
Look at jquery UI widget and jSTree

Categories