Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Old 11-23-2008, 05:05 AM String outpu
Skilled Talker

Posts: 94
Trades: 0
How do you get a second line, or should I say break, in a string output?

If the output is text and I want it to display 2 lines of text in instead of just one line, how would I do this?

{
strString = " First line of text.";
}

How can I get a Second line of text to out put on to a next line?
IG88 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-23-2008, 11:25 AM Re: String outpu
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
insert a <br> where needed
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 11-23-2008, 11:39 AM Re: String outpu
Novice Talker

Posts: 6
Name: saqib javed
Trades: 0
Quote:
Originally Posted by chrishirst View Post
insert a <br> where needed
does this work or not
saquu is offline
Reply With Quote
View Public Profile
 
Old 11-23-2008, 12:26 PM Re: String outpu
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
try it and find out!
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 11-23-2008, 02:55 PM Re: String outpu
Skilled Talker

Posts: 94
Trades: 0
No unfortunately that does not work.

I tried...

strString = " First line of text. <br> Second line of text.";

and

strString = " First line of text." <br> "Second line of text.";

abd some other ways but nothing seems to work
IG88 is offline
Reply With Quote
View Public Profile
 
Old 11-23-2008, 04:31 PM Re: String outpu
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
as part of the string!!!!!

HTML is only text.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?

Last edited by chrishirst; 11-23-2008 at 04:33 PM..
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 11-23-2008, 07:04 PM Re: String outpu
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,898
Name: Keith Marshall
Location: Connecticut
Trades: 0
If you're looking for a linebreak in an alert dialog or something similar, you can use the newline characture \n - for example:

var txtString = 'This is the first line\nThis is the second line';

alert(txtString);
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 11-24-2008, 08:32 PM Re: String outpu
Skilled Talker

Posts: 94
Trades: 0
mgraphic your suggestion did not work as well.

I also tried...

Code:
        strEmptyString = "";
        strCatSelectedString =    "You have selected a category.";
        strCatSelectedString =("<br />");
        strCatSelectedString =    "Please click Continue to move onto the next step.";
and

Code:
        
        strEmptyString = "";
        strCatSelectedString =    "You have selected a category.";
        strCatSelectedString = ("\n");
        strCatSelectedString =    "Please click Continue to move onto the next step.";

Last edited by IG88; 11-24-2008 at 08:33 PM..
IG88 is offline
Reply With Quote
View Public Profile
 
Old 11-24-2008, 08:42 PM Re: String outpu
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Your code above will result in strCatSelectedString being, "Please click Continue to move onto the next step." only BTW
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 11-24-2008, 08:57 PM Re: String outpu
Skilled Talker

Posts: 94
Trades: 0
Yes I am aware of that. This is why I came here for help.
IG88 is offline
Reply With Quote
View Public Profile
 
Old 11-24-2008, 10:44 PM Re: String outpu
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,898
Name: Keith Marshall
Location: Connecticut
Trades: 0
OK - Now I understand your question!

Code:
        strEmptyString = "";
        strCatSelectedString +=    "You have selected a category.";
        strCatSelectedString +=("<br />");
        strCatSelectedString +=    "Please click Continue to move onto the next step.";
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 11-25-2008, 12:21 PM Re: String outpu
Skilled Talker

Posts: 94
Trades: 0
The addition of the + does not work. It put out "Undefined" before the second line of text.
I tried changing it around with the + also with no luck.
IG88 is offline
Reply With Quote
View Public Profile
 
Old 11-25-2008, 12:37 PM Re: String outpu
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
A link to the page with your code in it please,
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 11-25-2008, 07:28 PM Re: String outpu
Skilled Talker

Posts: 94
Trades: 0
Quote:
Originally Posted by chrishirst View Post
A link to the page with your code in it please,
Sorry, everything is local at the moment. But here is the whole JavaScript file...

Code:
<!-- 3    //IE but not a Mac
 4    if ((navigator.appVersion.indexOf("MSIE")!= -1) && (navigator.appVersion.indexOf("Mac") == -1))
 5    {
 6        strEmptyString = "                                                     ";
 7        strCatSelectedString = "Category Selected - Click Next.           ";
 8
 9        //can we use this function? (forget about early IE browsers)
10        blnIE = (document.getElementById) ? true : false;
11    }
12    else
13    {
14        strEmptyString = "";
15        strCatSelectedString =    "You have selected a category.";
16        strCatSelectedString =("<br />");
17        strCatSelectedString =    "Please click Continue to move onto the next step.";
18
19    }
20
21    //IE only
22    if (blnIE)
23    {
24        //tables to border
25        var docTableArray = new Array;
26        var intTableSubmit = 0;
27
28        //tables : hard code for now
29        docTableArray[0] = document.getElementById('table_0');
30        docTableArray[1] = document.getElementById('table_1');
31        docTableArray[2] = document.getElementById('table_2');
32        docTableArray[3] = document.getElementById('table_3');
33        docTableArray[4] = document.getElementById('table_4');
34        docTableArray[5] = document.getElementById('table_5');
35        docTableArray[6] = document.getElementById('table_submit');
36        intTableSubmit = 6;
37
38        docTableArray[0].style.background = hexHighlightOn;    //highlight the first box for them to select
39    }
40
41    var i = 0;
42
43    //selectors to populate
44    var docSelectorArray = new Array;
45    var intLevels; // = categoryLevel.length; //number of levels in our form
46    var selectorLoop = 0;
47
48    //submit button
49    var submitButton;
50
51    //category_ID
52    var addl_category_id;
53
54    //build small arrays that we can index by id later
55    for (i = 0; i < document.ad_create_form.elements.length; i++)
56    {
57        if (document.ad_create_form.elements[i].name.indexOf("selector_") != -1) //cat selectors
58        {
59            docSelectorArray[selectorLoop] = document.ad_create_form.elements[i];
60            selectorLoop++;
61        }
62        else if (document.ad_create_form.elements[i].name.indexOf("category") != -1) //categoryID
63        {
64            addl_category_id = document.ad_create_form.elements[i];
65        }
66        else if (document.ad_create_form.elements[i].name.indexOf("form_next_step") != -1) //submit button
67        {
68            submitButton = document.ad_create_form.elements[i];
69        }
70    }
71
72    intLevels = docSelectorArray.length;    //number of levels in our form
73    submitButton.disabled = true;            //disable, will be enabled if appropriate
74
75    for (i = 1; i < selectorLoop; i++)
76    {
77        docSelectorArray[i].disabled = true;    //disable all these boxes
78        if (blnIE)
79        {
80            docSelectorArray[i].style.background = hexDisabled;    //set an obvious disabled colour
81        }
82    }
83//-->
IG88 is offline
Reply With Quote
View Public Profile
 
Old 11-25-2008, 08:14 PM Re: String outpu
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
There is obviously something somewhere in whatever we are NOT seeing,

the problem javascript works perfectly well.

http://www.modtalk.co.uk/demo/temp/
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to String outpu
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.38250 seconds with 12 queries