/    Sign up×
Community /Pin to ProfileBookmark

document.write command with formatting & objects

I want to use the document.write command to display form reults. This works fine until I combine it with html tags for formatting. How can I get the code below to work?

-cmotor

CODE:
document.write(‘<html><head><link rel=”stylesheet” href=”styles/scream_graylink.css”></head><span class=”boldtext”>Name : + document.Returnform.customer_name.value</span></html>’)

it should look like this:

Name: Joe

to post a comment
JavaScript

7 Comments(s)

Copy linkTweet thisAlerts:
@CharlesSep 07.2003 — [font=georgia]Just a hunch but I don't think that relative URLs are going to work there.[/font]
Copy linkTweet thisAlerts:
@cmotorauthorSep 07.2003 — Thanks for the response. The reletive link to the style sheet does work. But, to make the code simpler (for now) let's try the example below:


document.write('<font face="arial" size="2" color="990000">"Name :"+document.Returnform.customer_name.value</font>')


The code above displays the following results with the correct formatting (this is exactly what is shown in the window):

Name :+document.Returnform.customer_name.value


But, I want it to display:

Name: Joe


I think this is a syntax issue. I need the the correct syntax when working with formatting tags and objects for the document.write command. I know how to get it to work with either formatting tags or objects, but not both together.


Thanks,

-cmotor
Copy linkTweet thisAlerts:
@CharlesSep 07.2003 — [font=georgia]Yes, I missed it before. JavaScript doesn't do any variable substitution.

[font=monospace]document.write('<span style="font-family:arial; font-size:110%; color#900">Name: ', document.Returnform.customer_name.value, '</span>')[/font]

But how is your site going to work for the 13% of users who do not use JavaSCript?[/font]
Copy linkTweet thisAlerts:
@cmotorauthorSep 07.2003 — Thanks, that worked.

But, I am confused by your question about how my site is going to work for the 13% who do not use javaScript. I mean wouldn't that question apply to everyone who is posting in this forum? Please explain, I want to reach as many users as possible (all things considered).

-cmotor
Copy linkTweet thisAlerts:
@CharlesSep 07.2003 — [font=georgia]As I mentioned, 13% of users do not use JavaScript (http://www.thecounter.com/stats/2003/May/javas.php). And some of those good people cannot use JavaScript because of some disability. THis doesn't mean that you ought to eschew JavaScript all together but that you ought to limit its use and that you should "Ensure that pages are usable when scripts, applets, or other programmatic objects are turned off or not supported." ([url=http://www.w3.org/TR/WCAG10/wai-pageauth.html#tech-scripts]WCAG 1.0 Checkpoint 6.3[/url].)[/font]
Copy linkTweet thisAlerts:
@cmotorauthorSep 07.2003 — Right, I have to use some javascript, no way around it. Afterall my navigation is the coolmenus3 from dhtmlcentral.com.

I could use the alert command instead of the document.write command. Do you think this is less likely to be turned off by users?

Thanks,

-cmotor
Copy linkTweet thisAlerts:
@CharlesSep 07.2003 — [font=georgia]Neither your "coolmenu" nor an alert nor document.write is going to work for folks who do not use JavaScript.[/font]
×

Success!

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