0

我一直在编写一个代码生成器,我可以在其中填写表单中的变量,按下生成并将代码调用到文本字段中。以前做过,但由于某种原因,这次我似乎无法让它工作。我要疯了!在这个例子中,我一直在尝试调用第一个表单字段的值“问题”这是一个在线页面的链接,这是我在页面中使用的代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Generate Newsletter</title>

<style type="text/css">
#image {
    background-color:#666;
    box-shadow: 2px 2px 10px #888888;
    display:block;
    padding-top:1px;
    padding-bottom:10px;
    padding-left:5px;
    padding-right:5px;
    color:#FFF;
}


</style>


<script language="javascript" type="text/javascript">

function generateCode(form){

issue = document.inputForm.issue.value;
Header = document.inputForm.Header.value;
SubHeader = document.inputForm.SubHeader.value;
Content = document.inputForm.Content.value;
ArticleImage = document.inputForm.ArticleImage.value;
ArticleImageLink = document.inputForm.ArticleImageLink.value;
DidyouknowConent = document.inputForm.DidyouknowConent.value;
DidyouknowImage = document.inputForm.DidyouknowImage.value;
DidyouknowImageLink = document.inputForm.DidyouknowImageLink.value;
Courtesy = document.inputForm.Courtesy.value;
CourtesyLink = document.inputForm.CourtesyLink.value;

document.inputForm.source.value = issue;

return issue;
}
</script>
</head>

<body>
<form name="inputForm" id="inputForm">
<div id="EditBox" style="width:600px; height:650px; padding:10px; background-color:#CCC; border:2px; border-bottom-color:#666; box-shadow: 2px 2px 10px #888888;"><!--- INPUT FIELD -->

        <div id="LeftEdit" style="float:left;"><!--- LEFT EDIT SIDE-->


            <p>Issue # 
                <input name="issue" type="input" size="10"  value="">
            </p>
            <p>Article Header<br />
                <input name="Header" type="input" size="45">
            </p>

            <p>Sub Header<br />
                <textarea name="SubHeader" cols="35" rows="3"></textarea>
            </p>

            <p>Content<br />
                <textarea name="Content" cols="35" rows="25"></textarea>
            </p>
        </div>

      <div id="RightEdit" style="float:right; margin-top:50px;"><!--- RIGHT EDIT SIDE-->
            <div id="image">
                <h4> Article Image </h4>
                <p>source URL<br />
                    <input name="ArticleImage" type="input" size="35" onClick="this.focus();this.select()">
                </p>
                <p>Image Link<br />
                    <input name="ArticleImageLink" type="input" size="35" onClick="this.focus();this.select()">
                </p>
            </div>
            <p>Did You Know Conent<br />
                <textarea name="DidyouknowContent" cols="28" rows="5"></textarea>
            </p>
            <div id="image">
                <h4> Did You know Image </h4>
                <p>source URL<br />
                    <input name="DidyouknowImage" type="input" size="35" onClick="this.focus();this.select()">
                </p>
                <p>Image Link<br />
                    <input name="DidyouknowImageLink" type="input" size="35" onClick="this.focus();this.select()">
            </p>
            </div>
            <p>Image courtesy of <input name="Courtesy" type="input" size="19"> <br />
                Link to <input name="CourtesyLink" type="input" size="30" onClick="this.focus();this.select()"> <br />
            </p>
        </div>

</div>
<div style="clear:both;">
    <input type="button" value="Generate Code!" onClick="javascript:generateCode();">
    <br>
    <textarea name="source" rows="7" cols="40" onClick="this.focus();this.select()" style="margin-top: 1.2px; margin-bottom: 1.2px; height: 200px; margin-left: 1.2px; margin-right: 1.2px; width: 500px; "></textarea>
</div>


</form>

</body>
</html>
4

2 回答 2

1

在此处输入图像描述这里拼写错误

DidyouknowContent

DidyouknowConent = document.inputForm.DidyouknowConent.value;  // DidyouknowConent

<textarea name="DidyouknowContent" cols="28" rows="5"></textarea> //DidyouknowContent
于 2013-03-20T04:55:39.940 回答
0

我在萤火虫中尝试了你的代码,它显示如下

TypeError: document.inputForm.DidyouknowConent is undefined

看看这个..

或者你可以尝试插入使用

<input type="button">

试试这个

<input type="submit">
于 2013-03-20T05:00:28.187 回答