我有很多单选按钮从我的数据库中获取值,如果设置为"1",我会选中单选按钮.
如果选中单选按钮,并且用户再次单击它,我仍然希望能够清除此按钮.有没有人有想法?
$radio1 从数据库中获取数据,将为0,1或2
<input value="1" name="radio1" type="radio"<?php if($radio1==1){echo " checked";} ?>>
<input value="2" name="radio2" type="radio"<?php if($radio1==2){echo " checked";} ?>>
Run Code Online (Sandbox Code Playgroud)
Varun Malhotra的答案略有修改: 我改变了2行代码,对我来说效果更好.但总的来说,Varun的答案是完美的!
$('input[type="radio"]').click(function(){
var $radio = $(this);
// if this was previously checked
if ($radio.data('waschecked') == true)
{
$radio.prop('checked', false);
$radio.data('waschecked', false);
}
else
{
$radio.prop('checked', true);
$radio.data('waschecked', true);
}
// remove was checked from other radios
$radio.siblings('input[type="radio"]').data('waschecked', false);
});
Run Code Online (Sandbox Code Playgroud) 我试图将数字取消格式化为原始形式,但保留它是否为负数.堆栈溢出的人引导我使用这个代码非常好用,但它没有保留负面.
任何人都可以帮助我更好地解决这个问题吗?
编辑 - 美元货币/正常数字
例:
1,234 = 1234
-1,234 = -1234
1,234.00 = 1234
1,234.56 = 1234.56
function numberUnformat($number)
{
$cleanString = preg_replace('/([^0-9\.,])/i', '', $number);
$onlyNumbersString = preg_replace('/([^0-9])/i', '', $number);
$separatorsCountToBeErased = strlen($cleanString) - strlen($onlyNumbersString) - 1;
$stringWithCommaOrDot = preg_replace('/([,\.])/', '', $cleanString, $separatorsCountToBeErased);
$removedThousendSeparator = preg_replace('/(\.|,)(?=[0-9]{3,}$)/', '', $stringWithCommaOrDot);
return (float) str_replace(',', '.', $removedThousendSeparator);
}
Run Code Online (Sandbox Code Playgroud) 现在我有一个Auth Factory设置在我的州去的时候运行cloud.我试图传递:cloud_id给那个authCheck()功能,但我不知道如何.
任何人都可以指出我正确的方向来改变这个:
resolve: { authenticated: authenticated }
Run Code Online (Sandbox Code Playgroud)
对于这样的事情:
resolve: { authenticated: authenticated(cloud_id) }
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
.factory('Auth', function($http, $state, $q) {
var factory = { authCheck: authCheck };
return factory;
function authCheck(cloud_id) {
return $http.post('/auth/check', {id:cloud_id});
}
})
.config(function($stateProvider, $urlRouterProvider, $locationProvider) {
$locationProvider.html5Mode(true);
$urlRouterProvider.otherwise('/cloud');
var authenticated = ['$q', 'Auth', '$rootScope', function ($q, Auth, $rootScope) {
var deferred = $q.defer();
Auth.authCheck(cloud_id).then(function(){ deferred.resolve(); }, function(){ deferred.reject(); });
return deferred.promise;
}];
$stateProvider
.state('cloud', {
url: '/cloud/:cloud_id',
templateUrl: 'pages/templates/cloud.html', …Run Code Online (Sandbox Code Playgroud) 现在,我将整个设备数据库复制到远程数据库中。
完成此操作后,我将使用过滤器从远程数据库中获取所有不超过1个月的数据,并将其带入我的设备。
过滤
{
_id: '_design/filters',
"filters": {
"device": function(doc, req) {
if(doc.type == "document" || doc.type == "signature") {
if(doc.created >= req.query.date) return true;
else return false;
}
else return true;
}
}
}
Run Code Online (Sandbox Code Playgroud)
复制
device_db.replicate.to(remote_db)
.on('complete', function () {
device_db.replicate.from(remote_db, {
filter: "filters/device",
query_params: { "date": (Math.floor(Date.now() / 1000)-2419200) }
})
.on('complete', function () {
console.log("localtoRemoteSync replicate.to success");
callback(true);
});
});
Run Code Online (Sandbox Code Playgroud)
我希望能够定期从我的设备中删除3个月以上的数据(在我已经知道已同步的足够旧的数据中)
但是只是因为我从设备中删除了数据,所以当我将数据复制回remote_db时,我也不想在此删除它。
如何复制设备上的特定数据,但复制时不翻译该删除内容?
由于某些原因,在 Chrome 上,我的视频容器元素底部出现白色底部边框。
<video id="cover" src="video.mp4" autoplay="" loop=""></video>
Run Code Online (Sandbox Code Playgroud)
有谁知道如何解决这一问题?
这是元素的计算样式video。
background-color:rgb(0, 0, 0);
border-bottom-color:rgb(0, 0, 0);
border-bottom-style:none;
border-bottom-width:0px;
border-image-outset:0px;
border-image-repeat:stretch;
border-image-slice:100%;
border-image-source:none;
border-image-width:1;
border-left-color:rgb(0, 0, 0);
border-left-style:none;
border-left-width:0px;
border-right-color:rgb(0, 0, 0);
border-right-style:none;
border-right-width:0px;
border-top-color:rgb(0, 0, 0);
border-top-style:none;
border-top-width:0px;
display:inline-block;
font-family:Times;
font-size:16px;
font-stretch:normal;
font-style:normal;
font-variant-caps:normal;
font-variant-ligatures:normal;
font-variant-numeric:normal;
font-weight:normal;
height:798.547px;
line-height:16px;
margin-bottom:0px;
margin-left:0px;
margin-right:0px;
margin-top:0px;
object-fit:contain;
opacity:1;
padding-bottom:0px;
padding-left:0px;
padding-right:0px;
padding-top:0px;
vertical-align:baseline;
width:1680px;
Run Code Online (Sandbox Code Playgroud) 我有一个像这样的文件夹结构:
/gallery/images/category1/
/gallery/images/category2/
/gallery/images/category3/
/gallery/images/category4/
/gallery/images/category5/
and so on..
Run Code Online (Sandbox Code Playgroud)
在这些文件夹中,有一堆图像.但是,这些类别文件夹总是在变化,名称也是如此.
我的目标是让jekyll auto为这些类别中的每一个生成一个单独的页面.然后在此页面中,循环浏览该文件夹中的每个图像并将其显示在页面上.
我需要什么帮助:
/gallery/images文件夹并获取所有文件夹/gallery/[FOLDER_NAME].html每个文件夹一旦我能够做到这一点,我知道我可以将关注作为页面的内容并且没问题.
{% for image in site.static_files %}
{% if image.path contains 'gallery/{{ FOLDER_NAME }}' %}
<img src="{{ site.baseurl }}{{ image.path }}" />
{% endif %}
{% endfor %}
Run Code Online (Sandbox Code Playgroud)
任何帮助或指导将不胜感激.
我的页面上有一个提示警报的按钮。如果该用户选择Yes,那么我希望该exit()函数运行。然而,按照现在的编码方式,由于某种原因什么也没有发生。
有谁知道我做错了什么?
import React, { Component } from 'react';
import { ActivityIndicator, AsyncStorage, Button, StatusBar, Text, StyleSheet, View, TextInput, Alert } from 'react-native';
type Props = {};
export default class IDScreen extends Component<Props> {
static navigationOptions = {
title: 'Identification',
};
exit = async () => {
alert("I should see this but I don't");
await AsyncStorage.clear();
this.props.navigation.navigate('Login');
}
promptExit() {
Alert.alert("Are you sure?", "You can't be serious.", [
{text: 'Yes, Sign out', onPress: async () => …Run Code Online (Sandbox Code Playgroud) 由于某些原因,在我的应用程序上创建的文档没有显示在我的远程couchdb数据库上。
我正在使用以下
import PouchDB from 'pouchdb-react-native'
let company_id = await AsyncStorage.getItem('company_id');
let device_db = new PouchDB(company_id, {auto_compaction: true});
let remote_db = new PouchDB('https://'+API_KEY+'@'+SERVER+'/'+company_id, {ajax: {timeout: 180000}});
device_db.replicate.to(remote_db).then((resp) => {
console.log(JSON.stringify(resp));
console.log("Device to Remote Server - Success");
return resp;
}, (error) => {
console.log("Device to Remote Server - Error");
return false;
});
Run Code Online (Sandbox Code Playgroud)
我得到一个成功的回应:
{
"ok":true,
"start_time":"2018-05-17T15:19:05.179Z",
"docs_read":0,
"docs_written":0,
"doc_write_failures":0,
"errors":[
],
"last_seq":355,
"status":"complete",
"end_time":"2018-05-17T15:19:05.555Z"
}
Run Code Online (Sandbox Code Playgroud)
当我转到远程数据库时,不会显示可在应用程序上搜索和获取的document_id。
注意:当我.from()从远程设备获取数据时,我会获取数据。由于某种原因,它只是没有将数据推出
javascript couchdb pouchdb react-native pouchdb-adapter-localstorage
现在,在我的React-Native应用程序中,我有以下内容:
fetch('http://localhost/SOMETHING', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer '+this.state.authtoken
}
})
Run Code Online (Sandbox Code Playgroud)
目标:让我的API知道UID正在拨打电话.我知道这应该是authtoken,但不同的用户可以使用相同的authtoken.
我最初的想法是在?uid=${UID}每个网址的末尾添加一个.但是,我有GET,POST,PATCH,以及他们自己的一组查询
另一个想法是使用UID数据添加标头值.
无论我选择什么,能够将这个值添加到每个FETCH而不必做其他工作是很棒的.
这是可能的吗?打开你会做什么的建议.
现在我只知道用户工作了多少天。我正在尝试将此查询更改为最连续的工作天数。
其中u12345为4u1 。2
这可以通过 BigQuery 语句来实现吗?
编辑我对以下查询有点接近,但我的u1得到 3 而不是 2。
SELECT MIN(e.timestamp) as date_created, e.uid, COUNT(e.uid) + 1 AS streak
FROM OnSite e
LEFT JOIN OnSite ee
ON e.uid = ee.uid
AND DATE(e.timestamp) = DATE(DATE_ADD(ee.timestamp, INTERVAL -1 DAY))
WHERE ee.uid IS NOT NULL
GROUP BY e.uid;
Run Code Online (Sandbox Code Playgroud)
架构(MySQL v5.7)
CREATE TABLE OnSite
(`uid` varchar(55), `worksite_id` varchar(55), `timestamp` datetime)
;
INSERT INTO OnSite
(`uid`, `worksite_id`, `timestamp`)
VALUES
("u12345", "worksite_1", '2019-01-01'),
("u12345", …Run Code Online (Sandbox Code Playgroud) javascript ×6
react-native ×3
couchdb ×2
html ×2
mysql ×2
php ×2
pouchdb ×2
reactjs ×2
angularjs ×1
html5-video ×1
jekyll ×1
node.js ×1
numbers ×1
pouchdb-adapter-localstorage ×1
radio-button ×1
regex ×1