How to substring one by one in one button in php ? Example: $myvar="abc"; i need one button when click 1 time=display a, click 2time display b, and click 3time display c. click how many time ?depend on string of $myvar.
最佳做法
How to substring one by one in one button in php ? Example: $myvar="abc"; i need one button when click 1 time=display a, click 2time display b, and click 3time display c. click how many time ?depend on string of $myvar.
最佳做法
你们应当研究这一ir。
不管怎么说,如果假设纽芬兰语为“Btn”的话,那就给你一些代码;
var str = abc ;
var n = 0;
var btn = document.getElementById( Btn );
btn.onclick = function() {
alert(str.substring(n, n + 1));
n = (n + 1) % 3;
};
Oh, i made a mistake. the semicolon at the end of "n = (n + 1) % 3" is not correct!(i carelessly used a chinese semicolon instead...)
var str = abc ;
var n = 0;
var btn = document.getElementById( Btn );
btn.onclick = function() {
alert(str.substring(n, n + 1));
n = (n + 1) % 3;
};
这可能是科索沃。
i 假定你用来显示的成分为“Txt”,可以是“span”或“div”或你喜欢的任何其他内容。
<a href="#" id="Btn">Click Me!</a>
<span id="Txt"></span>
---------------------------------------------------------------------------------------
function displayOneByOne(str) {
var n = 0;
var btn = document.getElementById( Btn ) //get the clickable element
var txt = document.getElementById( Txt ) //get the area to display the character
btn.onclick = function() {
txt.innerHTML = str.substring(n, n + 1);
------------------------------------------------
if (n < str.length) n++;
else return false;
------------------------------------------------
}
}
displayOneByOne("YOUR_STRING_HERE");
---------------------------------------------------------------------------------------
<a href="#" id="Btn">Click Me!</a>
<span id="Txt"></span>
---------------------------------------------------------------------------------------
function displayOneByOne(str) {
var n = 1;
var btn = document.getElementById( Btn ) //get the clickable element
var txt = document.getElementById( Txt ) //get the area to display the character
btn.onclick = function() {
if (n <= str.length)
txt.innerHTML = str.substring(0, n++);
return false;
}
}
displayOneByOne("YOUR_OWN_STRING");
--------------------------------------------------------------------------------------
如果你在点击“abc”的话,就会显示:
“a” ->
I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...
<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...
I found this script online that creates a thumbnail out of a image but the thumbnail image is created with poor quality how can I improve the quality of the image. And is there a better way to create ...
如何确认来自正确来源的数字。
Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...
I wonder there is a way to post a message to a facebook business page with cURL? thanks
I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...
How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...