0

我有这段代码,想在GoLargeSearch单击图像时将输入传递给我的函数。

<div id="s4-searcharea-large">
    <input accessKey="S" onkeydown="CoreInvoke('LargeSearchKeyDownGoSearch', event)" id="txtLargeSearchTerm" runat="server" class="ms-sharepointsearchtext" title="Enter search words" value="" maxLength="255" size="25" type="text" name="SearchString" /> 
    <div class="ms-searchimage">
        <span style="position: relative; width: 27px; display: inline-block; height: 27px; overflow: hidden" class="s4-clust">
            <a style="width: 27px; display: inline-block; height: 27px" id="onetIDGoSearchLarge" title="Search" onclick="GoLargeSearch(document.getElementById('txtLargeSearchTerm'))" href="javascript:">
                <img style="border-bottom: 0px; position: absolute; border-left: 0px; border-top: 0px; border-right: 0px;" alt="Search" src="/_layouts/GP_Custom/images/largesearch.png" />
            </a>
        </span>
    </div>
</div>

如何获取输入的值以将其传递给GoLargeSearch?这似乎不起作用:

onclick="GoLargeSearch(document.getElementById('txtLargeSearchTerm'))"
4

2 回答 2

3

您缺少获取该元素值的部分:

onclick="GoLargeSearch(document.getElementById('txtLargeSearchTerm').value)"
于 2013-03-27T20:21:56.183 回答
0

这行得通!

function GoLargeSearch (obj) { alert(obj.value); }

但这是非常难看的代码 =/ 你不能使用 JQuery 吗?

于 2013-03-27T21:02:21.403 回答