用javascript不是很熟悉:请问怎么实现方法将参数传递给js文件?

anantnt203120 2005-12-20 02:30:41
在页面中调用一个js文件,
<script language="JavaScript">
var eLong_Width = '800';
var eLong_High = '600';
</script>
<script language="javascript" src="http://localhost/FitSearch/function.js" charset="gb2312"></script>

页面中还有一个输入框和一个点击按钮,

js文件实现的是画了一个表格,我想实现:在输入框输入宽度,点击按钮后,输入框的数字作为参数,传递到js文件中,画出了这个宽度的表格。
...全文
323 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
anantnt203120 2005-12-21
  • 打赏
  • 举报
回复
有个问题是,当我用innerHTML写一个FORM时,抱错。
FallenAngel 2005-12-20
  • 打赏
  • 举报
回复
不能用document.write,用document.getElementById("xxx").innerHTML来实现吧
anantnt203120 2005-12-20
  • 打赏
  • 举报
回复
晕!~~~
要是这样能行,我早干了。实际需求不容许。

我现在就像实现,在JS文件里有个函数,网页面里动态插入表格图片等页面元素。
怎么实现?
myvicy 2005-12-20
  • 打赏
  • 举报
回复
你把按牛和输入框的代码防到display里一起重新输出一次。
anantnt203120 2005-12-20
  • 打赏
  • 举报
回复
js 文件是这样的:
function display(width)
{
document.writeln(' <table width="' + width + '">');
document.writeln(' <tr>');
document.writeln(' <td>');
document.writeln(' </td>');
document.writeln(' </tr>');
document.writeln('</table>');
}


按钮click事件执行的是
display(400)

可是一执行,按钮和输入框都没有了,只写了一个表格
怎么留住按钮和输入框呢?
anantnt203120 2005-12-20
  • 打赏
  • 举报
回复
我页面是这样的:
<tr>
<td><asp:textbox id="TextBox1" runat="server" EnableViewState="True"></asp:textbox></td>
</tr>
<tr>
<td>
<script language="javascript" src="http://localhost/FitSearch/function.js" charset="gb2312"></script>
</td>
</tr>
<tr>
<td>
<asp:Button id="Button1" runat="server" Text="Button"></asp:Button></td>
</tr>

hhjjhjhj 2005-12-20
  • 打赏
  • 举报
回复
就看作是把http://localhost/FitSearch/function.js内容全部复制到<script></script>一样,你就明白怎么做了.
friendlyFour 2005-12-20
  • 打赏
  • 举报
回复
将http://localhost/FitSearch/function.js
中的函数定义中的width,height换成变量
然后用实际的width,height调用函数

87,901

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧