简体   繁体   English

尚未提交表单时无法进行onchange提交

[英]onchange submit when form has not been submitted yet does not work properly

I have a page with 2 iframes: one iframe consists of a html-form, and the other one is a graph that is controlled by the ouput of the form. 我有一个包含2个iframe的页面:一个iframe由html表单组成,另一个iframe是由表单输出控制的图形。 I have included a javascript code that automaticaly submits when I change my choice in a dropdown menu, hence adapting the graph to the new parameters. 我包含了一个javascript代码,当我在下拉菜单中更改选择时会自动提交,从而使图形适应新参数。 This works perfectly when I have already submitted the form manually and then change the parameters. 当我已经手动提交表单然后更改参数时,这将完美地工作。 However, when I haven't outputted a graph before, and I change the parameters, the second iframe shows a copy of the form in stead of the graph.. Can anyone help me with this issue? 但是,当我之前没有输出图形并更改参数时,第二个iframe会代替该图形显示该表单的副本。有人可以帮助我解决此问题吗? I can't seem to find the problem.. This is a part of the code I used for the form: 我似乎找不到问题。.这是我用于表单的代码的一部分:

<select id="Graf1" onchange="makeChoice5();updateSelect(this,'Graf2');this.form.submit();" name="graf1">
    <option value="other">---------- Kies ---------- </option>
    <option value="1">Temperatuur</option>
    <option value="2">Relatieve vochtigheid</option>
    <option value="3">Straling</option>
    <option value="4">Dendrometer 1</option>
    <option value="5">Dendrometer 2</option>
    </select>

And this is the code for the manual submit buttons: 这是手动提交按钮的代码:

<input type="submit"
style="
font-family: verdana;
font-weight: bold;"
value="Bekijk Grafiek" onclick="action='grafiek.php'; this.form.target='grafiek';return true;" >
</br>
<input type="submit"
style="
font-family: verdana;
font-weight: bold;"
value="Printvriendelijke versie" onclick="action='grafiekPrint.php'; this.form.target='grafiek';return true;" >

It is tough to say without your entire form code and javascript, but my guess is that you don't have your target and action set up initially. 没有完整的表单代码和javascript很难说,但是我的猜测是您最初没有设置目标和操作。 Thus, when you submit it via the onchange, it doesn't have anywhere to go. 因此,当您通过onchange提交它时,它无处可去。 However, when you click your buttons, you then set your form target and action, so future changes to your select will work, which seems to be exactly what you are experiencing. 但是,当您单击按钮时,就可以设置表单目标和操作,这样将来所做的选择更改就可以了,这似乎正是您所遇到的。 Thus, try putting this on your form: 因此,尝试将其放在表单上:

<form target="grafiek"..>

and setting up your action variable on page load to the default you would like it to do. 并将页面加载时的操作变量设置为您想要的默认值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM