/    Sign up×
Community /Pin to ProfileBookmark

Hi,

i would like to create an html generator.

I have a form for user to key in the info. One of the textbox for user to key in heading. after user key in the heading and generate the html. The output is sth like
…..
<h1>Heading</h1>

What i would like to improve is to let user to select the font size so that if the user select different font size. It will output the html code look sth like
<h1>[COLOR=”Red”]<font size=”14″>[/COLOR]Heading[COLOR=”Red”]</font>[/COLOR]</h1>
….

Here is my java scripts

[code]
<script type=”text/javascript”>
function generateCode(form){

//Header
title = document.inputForm.title.value;
metaDescription = document.inputForm.metaDescription.value;
metaKeywords = document.inputForm.metaKeywords.value;

//Website Content
headingtext = document.inputForm.headingtext.value;
tagline = document.inputForm.tagline.value;
subtagline = document.inputForm.subtagline.value;

output =
‘<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.1//EN” “http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd”>n’ +
‘<html>n’ +
‘<head>n’ +
‘<title>n’ +
((title) ? ” + title : ”) + ‘</title>n’ +
((metaKeywords) ? ‘<meta name=”keywords” content=”‘ + metaKeywords + ‘”>n’ : ”) +
((metaDescription) ? ‘<meta name=”description” content=”‘ + metaDescription + ‘”>n’ : ”) +
‘<meta name=”revisit-after” content=”7 Days” />n’ +
‘<meta name=”robots” content=”index,follow” />n’ +
‘<link rel=”stylesheet” type=”text/css” href=”default.css” media=”screen”/>n’ +
‘<body>n’ +
((headingtext) ? ‘<h1>’ + headingtext + ‘</h1><br/>n’ : ”) +
((tagline) ? ‘<h2>’ + tagline + ‘</h2><br/>n’ : ”) +
((subtagline) ? ‘<h3>’ + subtagline + ‘</h3><br/>n’ : ”) +
‘</body>n’ +
‘</html>n’;

document.inputForm.source.value = output;
return output;
}

function preview() {
var htmlCode;
htmlCode = generateCode();
targetURL = “/preview/preview.cfm?htmlCode=” + htmlCode;
window.open(targetURL, “newWindow”, “width=500,height=400,top=100,left=100,toolbar=no,menubar=no,location=no,scrollbars=yes”);
}
</script>
[/code]

Hope i can get help here.
i am testing my code here [url]www.malaysia-tractors.com[/url]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@CoyotelabFeb 12.2009 — [CODE]((fontsize) ? 'font-size:' + fontsize + ';' : '')[/CODE]
[code=html]<select style="height: 20px;" name="fontsize">
<option style="font-size: 8px;" value="8px"> 8px </option>
<option style="font-size: 9px;" value="9px"> 9px </option>
<option style="font-size: 10px;" value="10px"> 10px </option>
<option style="font-size: 12px;" value="12px"> 12px </option>
<option selected="selected" style="font-size: 14px;" value="14px"> 14px </option>
<option style="font-size: 16px;" value="16px"> 16px </option>
<option style="font-size: 18px;" value="18px"> 18px </option>
<option style="font-size: 22px;" value="22px"> 22px </option>
<option style="font-size: 48px;" value="48px"> 48px </option>
</select>[/code]
Copy linkTweet thisAlerts:
@qiqinuinaifen12authorFeb 13.2009 — Where should i put below code in side my java scrip?

[CODE]
((fontsize) ? 'font-size:' + fontsize + ';' : '')
[CODE]
×

Success!

Help @qiqinuinaifen12 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.7,
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,
)...