Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Textbox in a Textarea 1

Status
Not open for further replies.

adninja

Programmer
May 11, 2005
11
US
Hello, I am very new to JavaScript and I was wondering if it is possible to have a function place a textbox in the textarea of a forum I administrate. The purpose of this is for the dice roller I coded. It currently does a doInsert of the roll results that my members can easily edit to suit their needs. I want it to place a readonly textbox in the textarea they type prior to their submission of the post so that they can see what they rolled and continue on with the story without being able to edit it. I have heard of a few commands like EMBED and OBJECT, but (if those work that way) how would I go about using it?
 
A textarea is a form element, and so is a text input. As far as I know, there's no way to embed one element inside another.

EMBED and OBJECT are completely separate tags from what you described.

Lee
 
It is possible that - graphically - whatever you are imagining can be done, but I don't think it would be very useable because this combination of elements cannot be inline - the closest you could get is having one float ontop of the other, and there may be complications with that anyway.

In either event, you will not be able to prevent posters from re-rolling because they can refresh the page ;)

I tackled this problem some years ago, but in my case only iterations of D6 were required.

My solution was a server-side modification to me BBS that generated random values, and hardcoded images into the post text with an alt="'+value+'" to expose anyone who might think it was clever to try the BBCode tag ;)

One weakness was that editing the post would cause re-rolls. Due to the inline nature of these my solution (the dice which were added like smilies), the number of dice could change between edits! I did not think it viable to store dice results for each post. Instead, I thought it best to use a different set of images/colours for posts that were edited.

Other solutions may be available to you, depending on your server features, or the BBS you are using.

--Glen :)

Memoria mihi benigna erit qui eam perscribam
 
If you desire a cheap & cheerful solution, you can add the disabled="true" attribute to input elements to prevent editing the value.

--Glen :)

Memoria mihi benigna erit qui eam perscribam
 
>> you can add the disabled="true" attribute

or readonly="readonly"


-jeff
try { succeed(); } catch(E) { tryAgain(); } finally { rtfm(); }
i like your sleeves...they're real big
 
Actually, what stormbird suggested is about what I need. The reroll would not be a problem, because refreshing the page would mean they would have to input all of the text again. A reroll like that would not matter that much since the player would not be able to change the result outright, but instead would have to go through all of the trouble of: refresh, paste, roll; refresh, paste, roll... until they get what they want. Now, will the floating textbox be submitted in the post along with the text? If so, that will e the solution I use.

My code can do a roll of any type of die you can think of (even ones not manufacture and ones that have odd and even negative sides). I just used the Math.random and Math.round commands along with the proper variables.

I am going to get to work implementing the solution you suggested. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top