/    Sign up×
Community /Pin to ProfileBookmark

sentence generator

I’m trying to make a dynamic page that does something kind of arrbitrary like making a sentence. More specifically, I want a form where a user can enter thier name, and hieght. Then, when they click submit I am trying to get it the sentence to show up in a text box below that would say something like “Hi, Ashley, you are 5’8″!” Sounds kinda stupid and basic but it’s kicking my ***. I’ve kind of used elements from the scripts on this site to do this.

Here’s what I have so far:
<html>
<head>
<script language=”Javascript”>
function beginGenerator() {
var name = document.generator.name.value;
var height = document.generator.height.value;

}
</script>
</head>

<FORM name=”generator”><B>Input:</B><BR>
<TABLE cellPadding=0>
<TBODY>
<TR>
<TD>Name: <INPUT type=”text” name=”name”> &nbsp;&nbsp;&nbsp;
</tr>
<tr>
<TD>Height: <INPUT type=”number” name=”height”> &nbsp;&nbsp;&nbsp;
</tr>
<tr>
<TD><INPUT onclick=”beginGenerator();” type=”button” value=”Generate”>
</TD>
</TR>
<TR>
<TD></TD>
</TD>
</TR>
</TBODY>
</TABLE>
<SPAN id=”windowMarker”><B>Output:</B>
<BR />
<TEXTAREA name=”outputField” rows=”10″ wrap=”off” cols=”88″></TEXTAREA>
</FORM>
</body>
</html>

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@cootheadMar 20.2005 — Hi there zapateron,

and welcome to these forums. ?

try it like this...
[color=navy]&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
&lt;title&gt;form stuff&lt;/title&gt;

&lt;meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" /&gt;

&lt;style type="text/css"&gt;
/*&lt;![CDATA[*/
#container {
width:270px;
border:3px double #000;
padding:10px;
margin:auto;
background:#ccc;
}
div {
margin:5px;
font-family:verdana;
font-size:16px;
color:#000;
}
.bold {
font-weight:bold;
}
label {
display:block; <br/>
width:70px;
float:left;
}
.info {
width:180px;
}
#button {
color:#000;
}
input,textarea {
font-family:verdana;
font-size:16px;
color:#006;
}
textarea {
width:250px;
height:155px;
}
/*//]]&gt;*/
&lt;/style&gt;

&lt;script type="text/javascript"&gt;
//&lt;![CDATA[
function beginGenerator() {

var df=document.forms[0];
var name=df[0].value;
var height=df[1].value;

<i> </i> df[3].value="Hi, "+ name+", you are "+ height+" !";
}
//]]&gt;
&lt;/script&gt;

&lt;/head&gt;
&lt;body&gt;

&lt;div id="container"&gt;

&lt;form action="#" &gt;
&lt;div class="bold"&gt;Input:&lt;/div&gt;
&lt;div&gt;&lt;label&gt;Name:&lt;/label&gt;&lt;input class="info"type="text" /&gt;&lt;/div&gt;
&lt;div&gt;&lt;label&gt;Height:&lt;/label&gt;&lt;input class="info" type="text" /&gt;&lt;/div&gt;
&lt;div&gt;&lt;input id="button" type="button" value="Generate" onclick="beginGenerator();" /&gt;&lt;/div&gt;
&lt;div class="bold"&gt;Output:&lt;/div&gt;
&lt;div&gt;&lt;textarea cols="" rows=""&gt;&lt;/textarea&gt;&lt;/div&gt;
&lt;/form&gt;

&lt;/div&gt;

&lt;/body&gt;
&lt;/html&gt;[/color]


[i]coothead[/i]
Copy linkTweet thisAlerts:
@nusenseMar 20.2005 — Hmmmmm

Sounds like homework....
Copy linkTweet thisAlerts:
@zapateronauthorMar 20.2005 — HAHA Nah, it's just me trying to get a grasp of Javascript. I know a few programming lanuages, but I find Javascript is really hard to learn. If any of you have websites that you refernce often, please let me know about them!

Thanks for the help, coothead.
×

Success!

Help @zapateron spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...