如果标题不太清楚,但我不知道如何更精确地进行操作,我很抱歉。如何从其他函数调用未知的“onChange”函数
我有这样的代码:
<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>
我需要在F1领域,以示“牛顿”在F2写东西的时候。我只能修改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进行更改。
谢谢@Ram。这是我需要做的,但我不知道函数的名称或参数。查看编辑过的帖子。我需要一种动态的方式来加载这些功能。 – Memochipan