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
Adding some html tags using javascript
Old 11-27-2008, 03:46 PM Adding some html tags using javascript
jason_bristol's Avatar
Ultra Talker

Latest Blog Post:
New site - ConnectFrench.com
Posts: 310
Name: Jason Eyermann
Location: england bristol
Trades: 0
I have the following text...

<select>
<option>product name (+£4.50)</option>
</select>

I want to be able to use javascript or php to insert tags around (+£4.50) so that it is changed to...

<select>
<option>product name <div>(+£4.50)</div></option>
</select>

Does anyone know of a string function I could use to find ( and then place the tags either side of the brackets.

Thanks
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
jason_bristol is offline
Reply With Quote
View Public Profile Visit jason_bristol's homepage!
 
 
Register now for full access!
Old 11-27-2008, 05:53 PM Re: Adding some html tags using javascript
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
<div> tags are not allowed inside option elements

the <select> element is an inline element and as such cannot contain block element such as <div>s.
__________________
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-27-2008, 06:16 PM Re: Adding some html tags using javascript
jason_bristol's Avatar
Ultra Talker

Latest Blog Post:
New site - ConnectFrench.com
Posts: 310
Name: Jason Eyermann
Location: england bristol
Trades: 0
yes, of course. I don't know why I said DIV i meant SPAN, or EM. I was just using it as an example. sorry bad example.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
jason_bristol is offline
Reply With Quote
View Public Profile Visit jason_bristol's homepage!
 
Old 11-27-2008, 06:27 PM Re: Adding some html tags using javascript
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
NP

best way is just insert them at creation time, but it's not difficult to loop through the option nodes of a select and run a simple replace on the brackets.

Code:
textObj.replace("(","<em>(")
textObj.replace(")",")</em>")
__________________
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 Adding some html tags using javascript
 

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.19182 seconds with 12 queries