Click to See Complete Forum and Search --> : document.write command with formatting & objects
cmotor
09-07-2003, 11:19 AM
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
Charles
09-07-2003, 11:27 AM
Just a hunch but I don't think that relative URLs are going to work there.
cmotor
09-07-2003, 12:05 PM
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
Charles
09-07-2003, 12:29 PM
Yes, I missed it before. JavaScript doesn't do any variable substitution.
document.write('<span style="font-family:arial; font-size:110%; color#900">Name: ', document.Returnform.customer_name.value, '</span>')
But how is your site going to work for the 13% of users who do not use JavaSCript?
cmotor
09-07-2003, 12:41 PM
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
Charles
09-07-2003, 12:52 PM
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." (WCAG 1.0 Checkpoint 6.3 (http://www.w3.org/TR/WCAG10/wai-pageauth.html#tech-scripts).)
cmotor
09-07-2003, 01:04 PM
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
Charles
09-07-2003, 01:14 PM
Neither your "coolmenu" nor an alert nor document.write is going to work for folks who do not use JavaScript.