0
   

How to make a portion of string italics

 
 
Reply Fri 19 Jun, 2015 06:48 am
Hi guys,

I am trying to take some inputs, put them next to eaxh other in a order then dispkay them, one part of it I want to be in italics, which I dont know how to do that. for instance:
iputs are
Apple
Orange
Banana

Out put: "Apple, "+"Orange"+ "and"+"Banana"

If I want the Orange to be in italics how can I do that? there are lots of recommendations on the net about using italic() but they don't tell how and in what step use the italic()

Thanks for you help
  • Topic Stats
  • Top Replies
  • Link to this Topic
Type: Question • Score: 0 • Views: 1,358 • Replies: 5
No top replies

 
maxdancona
 
  1  
Reply Fri 19 Jun, 2015 08:15 am
@aryazdani,
How are you displaying these strings?

The answer is probably you want to use the <i> </i> tags (if you are displaying in HTML). The string italics() function does just that.

Try setting the output to

"Apple, <i>Orange</i>, and Banana"
aryazdani
 
  1  
Reply Fri 19 Jun, 2015 07:50 pm
@maxdancona,
Thanks for the reply.

In the form the user enters the Author's name and book title and after clicking a button, the result will be shown as: ((Book Tile +"by"+ Author's name)), but Author's name should be italic.

<label for="txtLastName">Author Name</label>
<input type="text" id="txtName" size="50" placeholder="Eg, Darwin" maxlength="50" style="font-style:italic">

<label for="txtTitle">Book Title</label>
<input type="text" id="txtTitle" size="40" placeholder="Eg, The Origin of Species" maxlength="100">

Please have a look at the input/ output I have below. Also please note that the placeholder in author's input text field in the form looks in italics but the input string when turns to output in text area is not in italics.

Input:
Author: Charles Dickens
Book: Oliver Twist

Output in a textarea:
Oliver Twist by Charles Dickens /* Charles Dickens should be in italics */

Thanks
maxdancona
 
  1  
Reply Fri 19 Jun, 2015 08:08 pm
@aryazdani,
How are you getting the text from the <input type="text"> tags to the textarea? Does your button have an onClick attribute?
aryazdani
 
  1  
Reply Fri 19 Jun, 2015 08:50 pm
@maxdancona,
Objects will be created then put together in Process function which it is called in button's onClick attribute.

in html:
<input type="button" value="Process" id="btnGenerate" data-inline="false" data-icon="check" data-iconpos="right" data-theme="a" onclick="Process()" >

then in Book.js :
function Prcess() {
var bTitle, bName;

bTitle = bookForm.txtTitle.value;
bName = bookForm.txtName.value;

concatBook = bTitle+" by "+bName.

DisplayBook(concatBook);
}

function DisplayBook() {

bookForm.myText.value = concatBook; //displays the results
}
maxdancona
 
  1  
Reply Fri 19 Jun, 2015 10:21 pm
@aryazdani,
So why not just put <i> </i> around bName in concatBook?
0 Replies
 
 

Related Topics

 
  1. Forums
  2. » How to make a portion of string italics
Copyright © 2025 MadLab, LLC :: Terms of Service :: Privacy Policy :: Page generated in 0.03 seconds on 02/05/2025 at 02:56:56