我试图弄清楚如何获得字符串中字符的倒数第二个索引.
例如,我有一个像这样的字符串:
http://www.example.com/website/projects/2
Run Code Online (Sandbox Code Playgroud)
我目前2通过使用获得该号码
$(location).attr('href').substring($(location).attr('href').lastIndexOf('/')+1);
但是,如果我想得到这个词projects怎么办?
有人可以帮我解决这个问题吗?提前致谢!
目前我有一个包含多个单选按钮的表单,您可以根据需要选择多个单选按钮.
问题是,当我通过我的表单将它们发送到PHP时,PHP只获取被检查的最后一个单选按钮值.我如何获得所有并将它们存储为数组或其他方式?
HTML:
<form action="php/submit.php" method="post" enctype="multipart/form-data">
<div class="spacing">
<a class="applicationLabel">Position(s) interested in:</a><br>
<input name="position" value="Project Manager" type="checkbox" /> Project Manager<br>
<input name="position" value="Content Developer" type="checkbox" /> Content Developer<br>
<input name="position" value="Graphic Designer" type="checkbox" /> Graphic Designer<br>
<input name="position" value="Digital Media Creator & Storyteller" type="checkbox" /> Digital Media Creator & Storyteller<br>
<input name="position" value="Programmer" type="checkbox" /> Programmer<br>
<input name="position" value="Server Engineer/Technician" type="checkbox" /> Server Engineer/Technician<br>
<input name="position" value="User Experience Designer" type="checkbox" /> User Experience Designer<br>
</div>
<input type="submit">
</form>
Run Code Online (Sandbox Code Playgroud)
PHP: …
我有一些jQuery,我附加文本,其中一些属性采取一些js变量.
<script>
var className = "COS 102";
var teacher = "Bob Teacher";
$("#classesDiv").append("<div className="+className+" teacher="+teacher+" class='class'></div>");
</script>
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是,当我将这些变量传递给元素时,它看起来像是className="COS"没有102之后.
有人知道为什么会这样吗?
我已经四处寻找,并且找到了一些对我有用的解决方案.我有一个带ID的表对象.我正在使用JQuery来获取被点击对象上的ID,并希望将其传递给我的数据源,但我无法做到.有人可以帮我吗?
HTML:
<a href="#" data-toggle="modal" data-target="#clusterpulse" id="cluster1">cluster1</a>
Run Code Online (Sandbox Code Playgroud)
JavaScript的:
<script>
$("table").delegate("a", "click", function() {
id2=$(this).attr('id');
});
$('#cluster_pulse_table').dataTable( {
"bprocessing": true,
"bserverSide": true,
"sAjaxSource": "../scripts/cluster_pulse.php?val=" + id2,
} );
</script>
Run Code Online (Sandbox Code Playgroud) 我试图从for循环内的字符串中删除一个空格.我能够让它为添加空间而工作,但删除不起作用.
这是我的代码:
letterHeight = 10
def nLetter():
x = 0
diagonal = ""
vertical = " "
while x < letterHeight:
print "*"+diagonal+"*"+vertical+"*"
diagonal += " "
vertical -= " "
x += 1
nLetter()
Run Code Online (Sandbox Code Playgroud)
错误: TypeError: unsupported operand type(s) for -=: 'str' and 'str'