如果标题不太清楚,我很抱歉,但我不知道如何更准确。
我有这个代码:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>Test</title>
<script type="text/javascript">
function p1() {
document.getElementById('f1').value = 'Isaac';
}
function p2() {
x=document.getElementById('f1');
x.value += ' Newton';
}
</script>
</head>
<body>
<form action="" method="get">
<input type="text" id="f1" name="f1" onChange="p2()">
<input type="text" id="f2" name="f2" onChange="p1()">
<input type="submit" value=">">
</form>
</body>
</html>
在 f2 中写入内容时,我需要在 f1 字段中显示“Isaac Newton”。我只能修改 p1 函数。我不知道 p1 函数的名称,即使每次加载页面时都会更改它。
谢谢。
感谢你的回答。真正的输入字段是这样的:
<input type="text" id="tceforms-textfield-4e20ac55d3700" class="formField tceforms-textfield" name="data[tx_oriconvocatorias_publicadas][NEW4e20ac55cdc8f][cnom]_hr" value="" style="width: 460px; " maxlength="255" onchange="typo3form.fieldGet('data[tx_oriconvocatorias_publicadas][NEW4e20ac55cdc8f][cnom]','required,trim,tx_oriconvocatorias_autoLlenar','',1,'');TBE_EDITOR.fieldChanged('tx_oriconvocatorias_publicadas','NEW4e20ac55cdc8f','cnom','data[tx_oriconvocatorias_publicadas][NEW4e20ac55cdc8f][cnom]');">
我有 10 个不同类型的字段:select、text 和 textarea。
有没有办法从我的 onchange 函数加载这个动态代码?
我可以访问字段的名称,所以我想做类似的事情:
function p1() {
code + name.Onchange;
}
有可能的?我不知道正确的语法。
我也尝试了这些focus(),click(),select() and blur()
方法,但它们没有传达 Javascript 进行了更改。