在我的表单内,我有一个用户名文本框,其上显示有增量ID 它,我的问题是我想在ID之前在样本上添加一个文本“ user:” 图片下。我尝试将其插入value =“ user:phpcode”上,但是我的增量编号没有增加,希望您能在这一步中对我有所帮助。
SELECT users.*, roles.name as role_name FROM ...
这是我的模态代码示例:
<button type="button" class="btn" data-dismiss="modal"
data-toggle="modal" data-target="#exampleModal1" style=" color:#fff; background:#00bcd4" onClick="incrementValue()" value="Increment Value">No</button>
这是我的JavaScript:
<div class="modal fade right" id="exampleModal1" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true" data-backdrop="false">
<div class="modal-dialog modal-full-height modal-right" role="document">
<div class="modal-content">
<div class="modal-header blue accent-1">
<h3 class="mt-2" style="color:white;"><i class="fa fa-user-circle"></i> New User :</h3>
<a href="test1.php" button type="btn" class="close" aria-label="Close">
<span aria-hidden="true">×</span></a> </div>
<div class="modal-body">
<div class="row">
<div class="col">
<div class="md-form mt-0">
<input type="text" class="form-control" name="username"
id="username" style="width:45%; margin-top:20px;" readonly value="user:<?php
$sql='select max(id)
from test2';
$result = mysqli_query($conn,$sql);
$row = mysqli_fetch_row($result);
echo $row['0'];
?> ">
<label for="inputVisitorMD" style="font-size: 1rem; ">Username</label>
</div>
</div>
</div>
div class="text-center mt-2">
<button type="submit" id="submit" class="btn btn-info" style="width:98%; ">Log in <i class="fa fa-sign-in ml-1"></i></button>
</div>
</form>
<!-- Material form grid -->
</div>
</div>
</div>
</div>
答案 0 :(得分:0)
首先,您永远不会从附加的代码中调用增量功能。您可以直接在您的php中解决此问题(如果您运行的是php服务器,否则将无法正常工作……只是说因为您在此问题上没有php标记)
所以。您是否在“运行时”下多次递增此次数,而不是一次。如果只增加一个时间(而不是步长。(00001 +步长,1次)),则可以使用php轻松解决。
在后端的操作方法如下:
public ref class MainPage sealed: public INotifyPropertyChanged
{
public:
MainPage();
property DataType^ Data {
DataType^ get() {
return m_Data;
}
void set(DataType^ value) {
m_Data = value;
OnPropertyChanged("Data");
}
}
virtual event PropertyChangedEventHandler^ PropertyChanged;
private:
void OnPropertyChanged(Platform::String^ propertyName)
{
PropertyChanged(this, ref new PropertyChangedEventArgs(propertyName));
}
void Button_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
Data->Name = rand() & 1 ? "Test1" : "Test2";
OnPropertyChanged("Data");
}
DataType^ m_Data;
};
答案 1 :(得分:0)
这是我针对上述问题的解决方案,只想分享一下。 :)
<button type="button" class="btn" style=" color:#fff; background:#00bcd4" onClick="incrementValue()" value="Increment Value">No</button>
<div class="row">
<!-- Grid column -->
<div class="col">
<!-- Material input -->
<div class="md-form mt-0">
<input type="text" class="form-control" name="id" id="id" readonly style="width:45%; margin-top:30px;" value="<?php
$sql='select max(id)
from test2';
$result = mysqli_query($conn,$sql);
$row = mysqli_fetch_row($result);
echo $row['0'];
?> ">
<label for="inputVisitorMD" style="font-size: 1rem; ">User's ID</label>
</div>
</div>
</div>
<div class="row">
<div class="col">
<!-- Material input -->
<div class="md-form mt-0">
<input type="text" class="form-control" name="username" id="username" style="width:45%; margin-top:20px;" readonly value="user:00000<?php
$sql='select max(id)+1
from test2';
$result = mysqli_query($conn,$sql);
$row = mysqli_fetch_row($result);
echo $row['0'];
?> ">
<label for="inputVisitorMD" style="font-size: 1rem; ">Username</label>
</div>
</div>
</div>
我的JavaScript:
<script>
function incrementValue() {
var value = parseInt(document.getElementById('id').value, 10);
value = value || 0;
value++;
document.getElementById('id').value = ("00000" + value).substr(-5);
}
</script>