I like to use a jQuery mobile flip toggle switch to submit two status informations to control the two status of a relais.
Instead of using:
<input class="scene_btn" type="submit" onClick="request('key=1')" value="on" data-theme="d"</input>
<input class="scene_btn" type="submit" onClick="request('key=2')" value="off" data-theme="d"</input>
I'd like to use a jquery flip toggle switch, to switch on and off a relais.
<form>
<label for="flip-1">Flip toggle switch:</label>
<select name="flip-1" id="flip-1" data-role="slider">
<option value="off">Off</option>
<option value="on">On</option>
</select>
</form>
Does anybody know, how to to programm this?
Working example: http://jsfiddle.net/Gajotres/mC2ph/
HTML:
<!DOCTYPE html>
<html>
<head>
<title>jQM Complex Demo</title>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; minimum-scale=1.0; user-scalable=no; target-densityDpi=device-dpi"/>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.0-alpha.2/jquery.mobile-1.4.0-alpha.2.min.css"/>
<!--<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>-->
<script src="http://code.jquery.com/mobile/1.4.0-alpha.2/jquery.mobile-1.4.0-alpha.2.min.js"></script>
</head>
<body>
<div data-role="page" id="index" data-theme="a" >
<div data-role="header">
<h3>
First Page
</h3>
Next
</div>
<div data-role="content">
<form id="test-form">
<label for="flip-1">Flip toggle switch:</label>
<select name="flip-1" id="flip-1" data-role="slider">
<option value="off">Off</option>
<option value="on">On</option>
</select>
</form>
</div>
<div data-role="footer" data-position="fixed">
</div>
</div>
</body>
</html>
JavaScript:
$(document).on('pageinit', '#index', function(){
$(document).on( "slidestop", "#flip-1" ,function( event, ui ) {
console.log($("#flip-1").val());
$('#test-form').submit();
});
});
You can get solution here,
http://demos.jquerymobile.com/1.2.0/docs/forms/switch/events.html
There is a specification about "Methods" and "event" so, it may be helpful for you.
Related
I need to add a floating label to this select menu. I found this framework https://tronic247.com/material/ and it seem to have a select component but no floating label, So how to add it / Thanks for any help.
<!DOCTYPE html>
<html>
<head>
<title>My Material design Web Page</title>
<meta name="viewport" content="minimum-scale=1, initial-scale=1, width=device-width">
<!-- CSS at head -->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" />
<link href="https://res.cloudinary.com/tronic247/raw/upload/v1620900079/material.min.css" rel="stylesheet" />
</head>
<body>
<div class="container p-5">
<label for="rating">Choose a rating</label>
<select class="filled">
<optgroup label="Good">
<option value="5">5+</option>
<option value="10">10+</option>
<option value="" disabled="">10+</option>
</optgroup>
<optgroup label="Bad">
<option value="1">1</option>
<option value="2">2</option>
</optgroup>
</select>
</div>
<!-- JS at footer for optimized loading -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://res.cloudinary.com/tronic247/raw/upload/v1620900084/material.min.js"></script>
</body>
</html>
As far as I can see from the documentation, the library you use does not have an option for floating labels. Try some other library that does have floating labels, like Material Design Lite or another that has built-in this option.
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://code.getmdl.io/1.3.0/material.indigo-pink.min.css">
<script defer src="https://code.getmdl.io/1.3.0/material.min.js"></script>
<!-- Textfield with Floating Label -->
<form action="#">
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
<input class="mdl-textfield__input" type="text" id="sample3">
<label class="mdl-textfield__label" for="sample3">Text...</label>
</div>
</form>
<!-- Numeric Textfield with Floating Label -->
<form action="#">
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
<input class="mdl-textfield__input" type="text" pattern="-?[0-9]*(\.[0-9]+)?" id="sample4">
<label class="mdl-textfield__label" for="sample4">Number...</label>
<span class="mdl-textfield__error">Input is not a number!</span>
</div>
</form>
I just started using select2 jquery plugin . I am trying it on codepan . I added all cdn link (css,js, jquery etc) .But my select items do not change yet . here is my code :
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Meta -->
<meta charset="UTF-8" />
<title>My New Pen!</title>
<!-- Styles -->
<link rel="stylesheet" href="styles/index.processed.css">
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.4/css/select2.min.css" rel="stylesheet" />
</head>
<body>
<div style="width:600px;">
<form action="post">
<select name="" id="myselection">
<option value="dhaka"> Dhaka </option>
<option value="braishal"> Barishal </option>
<option value="Khulna"> Khulna </option>
<option value="rajshahi"> Rajshahi </option>
<option value="dinajpur"> Dinajpur </option>
</select>
</form>
</div>
<!-- Scripts -->
<script src="scripts/index.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.4/js/select2.min.js">
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#myselection').select2();
});
</script>
</body>
</html>
JQuery must be imported before Select2 script for it to work.
So the correct import order should be:
jQuery
Select2
Page specific Javascript
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Meta -->
<meta charset="UTF-8" />
<title>My New Pen!</title>
<!-- Styles -->
<link rel="stylesheet" href="styles/index.processed.css">
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.4/css/select2.min.css" rel="stylesheet" />
</head>
<body>
<div style="width:600px;">
<form action="post">
<select name="" id="myselection">
<option value="dhaka"> Dhaka </option>
<option value="braishal"> Barishal </option>
<option value="Khulna"> Khulna </option>
<option value="rajshahi"> Rajshahi </option>
<option value="dinajpur"> Dinajpur </option>
</select>
</form>
</div>
<!-- Scripts -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.4/js/select2.min.js">
</script>
<script src="scripts/index.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#myselection').select2();
});
</script>
</body>
</html>
Why does some parts of the first drop-down menu get hidden by another drop-down menu below in the following example:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="description" content="">
<meta name="author" content="">
<!-- Note there is no responsive meta tag here -->
<link rel="shortcut icon" href="../../docs-assets/ico/favicon.png">
<title>MarkerDB</title>
<!-- Bootstrap core CSS -->
<link rel="stylesheet" type="text/css" href="//netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" >
<link rel="stylesheet" type="text/css" href=//cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.6.2/css/bootstrap-select.min.css>
<!-- Custom styles for this template -->
<link href="http://getbootstrap.com/examples/non-responsive/non-responsive.css" rel="stylesheet">
</head>
<body>
<div class="container">
<form class="form-inline" action="/between/" method="get">
<div class="input-group">
<span class="input-group-addon">TestA</span>
<select name="tests" class="selectpicker form-control" data-live-search="true" title="Plese select a test ...">
<option selected value="1">Test1</option>
<option selected value="2">Test2</option>
</select>
<span class="input-group-btn">
<button class="btn btn-default" type="submit">Search!</button>
</span>
</div>
</form>
<hr>
<form class="form-horizontal" action="/compare/" method="get" role="form">
<div class="input-group">
<span class="input-group-addon">TestB:</span>
<select name='cultnames' class="selectpicker show-menu-arrow form-control" multiple data-max-options="2" data-live-search="true">
<option value="Test3">Test3</option>
<option value="Test4">Test4</option>
</select>
<span class="input-group-btn">
<button class="btn btn-default" type="submit">Search!</button>
</span>
</div>
</form>
<hr>
<HR>
</div> <!-- /container -->
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script type="text/javascript" src="//netdna.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.6.2/js/bootstrap-select.min.js"></script>
<script>
$('.selectpicker').selectpicker();
</script>
</body>
</html>
If you put z-index:0 on the input-group in the 2nd form it works ok.
...
<form class="form-horizontal" action="/compare/" method="get" role="form">
<div class="input-group" style="z-index:0;">
...
http://jsfiddle.net/kme2j8ma/
I found a code from w3schools for jquery mobile on and off slider input. But i don't know how to take out the value from the input and show it by PHP. Here is the HTML which was on w3schools:-
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.css">
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.js"></script>
</head>
<body>
<div data-role="page">
<div data-role="main" class="ui-content">
<form method="post" action="demoform.asp">
<label for="switch">Flip Toggle Switch:</label>
<input type="checkbox" data-role="flipswitch" name="switch" id="switch">
<br>
<input type="submit" data-inline="true" value="Submit">
</form>
</div>
</div>
</body>
</html>
Please tell me how to take the value from this input in PHP. Thanks in advance
if(isset($_POST['switch']))
{
echo "On. The user On the switch.";
}
else
{
echo "Off. The user kept the switch Off.";
}
i am using jqtransform plugin to create select input, i make some change in js file i am creating a select option instead of li and i create a differente script to get select option innerhtml but when i calling this function on window.onload function is working for not working second time.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta name="gmapkey" content="" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<title></title>
<link rel="stylesheet" href="jqtransformplugin/jqtransform.css" type="text/css" media="all" />
<link rel="stylesheet" href="demo.css" type="text/css" media="all" />
<script type="text/javascript" src="requiered/jquery.js" ></script>
<script type="text/javascript" src="jqtransformplugin/jquery.jqtransform.js" ></script>
<script language="javascript">
$(function(){
$('form').jqTransform({imgPath:'jqtransformplugin/img/'});
});
</script>
<script type="text/javascript">
function change () {
var jAm= document.getElementById('sltnew');
var jM= jAm.options[jAm.selectedIndex].text;
document.getElementById('catch').innerHTML=jM;
}
document.ajay.sltnew.onchange=change;
</script>
</head>
<body>
<form action="post.php" method="POST" name="ajay">
<div class="rowElem"><label>Input Text:</label><input type="text" name="inputtext"/></div>
<div class="rowElem"><label>Input Password:</label><input type="password" /></div>
<div class="rowElem"><label>Checkbox: </label><input type="checkbox" name="chbox" id=""></div>
<div class="rowElem"><label>Radio :</label>
<input type="radio" id="" name="question" value="oui" checked ><label>oui</label>
<input type="radio" id="" name="question" value="non" ><label>non</label></div>
<div class="rowElem"><label>Textarea :</label> <textarea cols="40" rows="12" name="mytext"></textarea></div>
<div class="rowElem">
<label>Select :</label>
<select name="select">
<option value="">1</option>
<option value="opt1"></option>
</select>
</div>
<div class="rowElem" style="float:left; width:500px; position:relative">
<label>Select Redimentionné :</label>
<select name="sltnew" id="sltnew" onchange="change ()">
<option value="opt1">Select states</option>
<option value="opt2">Option 2</option>
<option value="opt3">Option 3</option>
<option value="opt4">Option 4</option>
<option value="opt5">Option 5</option>
<option value="opt6">Option 6</option>
<option value="opt7">Option 7</option>
<option value="opt8">Option 8</option>
</select>
<div id="catch">select city</div>
</div>
<div class="rowElem"><label>Submit button:</label><input type="submit" value="Envoyer" /></div>
<div class="rowElem"><label>Reset button:</label><input type="reset" value="Annuler" /></div>
<div class="rowElem"><label>Input button:</label><input type="button" value="bouton" /></div>
</form>
</body>
</html>
change in jqtransform file what i made.
$wrapper.prepend('<div><span></span></div><select id="slt"></select>');
var $ul = $('select', $wrapper).css('width',$select.width()).hide();
/* Now we add the options */
$('option', this).each(function(i){
var oLi = $('<option>'+ $(this).html() +'</option>');
$ul.append(oLi);
});
just try this
http://www.pkoretic.net/csTransPie