【发布时间】:2018-04-19 11:40:54
【问题描述】:
<apex:page id="Page" standardController="Account" extensions="vidsav" sidebar="false">
<script src="/soap/ajax/20.0/connection.js" type="text/javascript"></script>
<script>
function dup() {
alert("test");
sforce.connection.sessionId = "{!$Api.Session_ID}";
var res = document.getElementById("Page:form:PB:sd:PBS:Name").value;
alert(res);
var qr = sforce.connection.query("select id, Name From Account WHERE name = '" + res + "'");
alert(qr);
if (qr.size != 0) {
if (confirm('Are you sure?')) {
alert('testdup');
}
return false;
}
}
</script>
<apex:form id="form">
<apex:pageBlock id="PB" >
<apex:pageBlockTable value="{!sc}" var="que" id="sd">
<apex:column value="{!que.id}"/>
<apex:column value="{!que.Name}" id="PBS"/>
<apex:column value="{!que.Industry}"/>
<apex:column >
<apex:commandLink action="{!deleteStudent}" onclick="if(!confirm('Are you sure?')) return false;" value="Del">
<apex:param value="{!que.Id}" name="idToDel" assignTo="{!SelectedStudentId}"/>
</apex:commandLink>
<apex:commandButton value="AddProcess" onclick="dup()" rerender="all"/ ></apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
<apex:inputText value="{!searchstring}" label="Input"/>
<apex:commandButton value="Search records" action="{!search}"/>
<apex:commandButton value="Clear records" action="{!clear}"/>
</apex:form>
</apex:page>
如何在 javascript 中获取顶点列值?这总是在 res 中不返回任何内容 var res = document.getElementById("Page:form:PB:PBS:Name").value; 警报(res);
如何通过javascript传递动作函数参数来调用apex方法
我们已经更改了 pageblocktable,之后我们定义了 id 也没有获得价值
var res = document.getElementById("Page:form:PB:sd:PBS:Name").value;
【问题讨论】:
-
你确定你的ID是正确的吗?你检查过浏览器中的代码吗?最后一部分 withe :Name 看起来有点奇怪
标签: javascript salesforce visualforce soql