473,386 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

New String Method wont work?

103 100+
I am in the learning stage of coding for Web. Here is my Code. I placed in bold and italic function that is not working.
<html>
<head>
<title>JavaScript Business Cards</title></head>
<body>
<h1>JavaScript Business Cards</h1>
<p>The Script Begins Here.</p><hr>
<script language= "JavaScript" type="text/javascript" src="Print_Card_Modified.js">
</script>
<p>The End of the Script.</p>
<script language="JavaScript" type="text/javascript">
//Adding a function to change sting appearance
function addHead(level){
html ="h" + level;
text = this.toString();
start = "<" + html + ">";
end= "</"+ html + ">";
return start + text + end;
}
Sting.prototype.heading = addHead;
document.write("this is modified text".heading(1));
</
script>
</body>
</html>
Jan 5 '11 #1

✓ answered by Rabbit

You probably meant to use String and not Sting. And yes, I agree, this is a convoluted way of getting this done.

5 1110
Dormilich
8,658 Expert Mod 8TB
there is no function Sting() defined.

isn’t this a bit over-complicated?
Jan 5 '11 #2
Rabbit
12,516 Expert Mod 8TB
You probably meant to use String and not Sting. And yes, I agree, this is a convoluted way of getting this done.
Jan 5 '11 #3
Brian Connelly
103 100+
Thanks for the input. It works after I corrected the Sting to String. Im in the learning stage...so everything I do will most likely be convoluted. If you have any other suggestions for me please fill free to suggest. Anyway thanks for the help...It was driving me nuts!
Jan 5 '11 #4
Brian Connelly
103 100+
Im learning...everything might turn out over-kill! Thanks for the help.
Jan 5 '11 #5
Dormilich
8,658 Expert Mod 8TB
If you have any other suggestions for me please fill free to suggest.
Expand|Select|Wrap|Line Numbers
  1. elem.innerHTML = "<h1>" + text + "</h1>";
Jan 6 '11 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Oliver Spiesshofer | last post by:
Hi, I have a script that calls an fopen() on an external URL. I can run the script from the server as an url fine. When however the script should be run from crontab, it does not work. I get ...
5
by: Catherine | last post by:
I am having a problem viewing asp pages on iis version 5.1 xp pro. HTML pages are viewable on http://localhost but .asp pages are not. I have created a test program called timetest.asp with the...
19
by: Allen Thompson | last post by:
sorry for the simple question, haven't done this in a while. when I use the following script it keeps displaying the value of "x" like a string. for example, if I type the number 7 in the prompt,...
0
by: Sebastian Sosna | last post by:
Hi there! iam trying a code snippet from MSDN heres the link : http://msdn.microsoft.com/library/default.asp?url=/library/en-us/netdir/netds/creating_groups.asp ive tried the code but it...
7
by: Christine | last post by:
My code has a split function that should split the text file of numbers. I've run this in previous programs as it is here and it worked, but now it wont work for some reason and returns...
1
by: Gary | last post by:
I have the following in my web.config.... <customErrors mode="RemoteOnly" defaultRedirect="Applicationerror.aspx"/> but, my error page does not display. Instead a 'Runtime Error' page...
14
by: squash | last post by:
The following code works fine in Firefox/Netscape but wont work in IE. I suspect the problem is with one of these two simple functions. If there is no obvious error Ill paste the entire code. ...
8
by: Mark12345 | last post by:
Hi folks, thanks for looking. I have a database that takes down order details. Each customer has there own priceid in the price table. the errors that I get say enter parameter value for:...
2
by: jcollins1991 | last post by:
im trying to make a program thats supposed to check whether 2 strings are anagrams of each other (anagram = same letters in both strings, but in different orders... "cool as wet art" , and "cs at...
2
by: Admiral | last post by:
Hi, Anyone knows how this works? I have made a textbox called Editbox1 and 10 buttons. b0, b1, b2 etc. What i want to do is when i press a button, b1 for example, a number 1 appears into...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.