how do you get text in a textfield into a table using document.write technique?

Discussion in 'HTML & Website Design' started by Jaguarjace, May 1, 2009.

  1. #1
    hey there,
    I'm trying to figure out how to get written text in a textfield to appear in a table using the document.write system.

    Say if somone writes "Welcome to my profile" in the textbox, then click the preview button, and "Welcome to my profile" appears straight away in a coloured table. I would also like a possible back button so the user can retype a different message in the textbox if he/she made a error in the message. for this button I just gonna simply use onclick="javascript:history.go(-1)" to get it back 1 page.

    heres a code for what i'm trying to do:
    <html>
    <head>
    <title>Profile Preview</title>
    </head>
    <body>
    <form name="sectiona">
    <input type="text" name="headlinei" size="63">
    <input type="button" value="Preview Section" onclick="showit();" name="headline">
    <input type="reset" value="Reset Section" name="resetheadline">
    </form>            
    <script>
    function showit() {
    document.write('<table border="1" cellspacing="0" width="50%" cellpadding="0">');
    document.write('<tr>');
    document.write('<td width="100%" height="200px" bgcolor="#FFFFCC">');
    document.write('' + document.forms.sectiona.headlinei.value);
    document.write('</td>');
    document.write('</tr>');
    document.write('</table>');
    }
    </script>
    </body>
    </html>
    Code (markup):
    The code
    document.write('' + document.forms.sectiona.headlinei.value);
    Code (markup):
    Confuses me so i'm unsure about it.
    I know its possible... a few years ago i had successfully done it but I have to get it all over again :(
    please help.
    -Jason
     
    Jaguarjace, May 1, 2009 IP