Forum Moderators: open

Message Too Old, No Replies

Write Contents of Text Field

         

noface0711

5:53 am on Apr 15, 2016 (gmt 0)

10+ Year Member



I have a page with 3 text fields and 1 dropdown menu.

I need a script that will print something like this on the screen (either as the text fields are completed or once the user presses a button):

Lorem ipsum <contents of text field 1>dolor sit <a href="<contents of drop down>">amet,</a> consectetur adipisicing elit, sed do eiusmod temper incididunt <content of text field 2> ut labore et dolors <content of text field 3>magna aliqua. Ut enum <img src="someimage.jpg" />ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

I need the output to be printed like the above so the user can copy/paste it into their html code so the html tags should remain in the output.

Any ideas how to do this (using jQuery is fine)?

lucy24

8:28 pm on Apr 15, 2016 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



so the user can copy/paste it into their html code so the html tags should remain in the output

You mean, replacing all < with &lt; right? (Closing brackets can either change to &gt; or remain as-is; I don't think it will make any difference in display.)

Or are you asking about the getBlahblahById part?

Chico_Loco

7:31 am on May 29, 2016 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you are still looking for an answer to this, what you need to do is place span tags in the content ( each with a unique "id" ) and create a javascript function that updates the innerHTML of the spans once once of the text fields is updated, using something like the onKeyUp.

I've done a simple jsfiddle for you to demonstrate: [jsfiddle.net...]