Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9

Thread: please help

  1. #1
    New Coder
    Join Date
    Sep 2011
    Posts
    25
    Thanks
    8
    Thanked 0 Times in 0 Posts

    please help

    Here is some code that I am working with

    --html--
    <INPUT type="text" name=a1c />

    --js--
    document.myquiz.a1c.value = "CORRECT!";


    How can I replace the string "Correct!" with an image???
    Something like this:
    document.myquiz.a1c.value = "<img src ...... />;


    Thank you

  • #2
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,398
    Thanks
    12
    Thanked 570 Times in 563 Posts
    Edit: facepalm
    Last edited by devnull69; 09-12-2011 at 08:08 PM.

  • #3
    Regular Coder
    Join Date
    Aug 2010
    Posts
    974
    Thanks
    19
    Thanked 212 Times in 210 Posts
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html lang="en">
    <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <meta name="generator" content="daveyerwin">
    <title>Untitled</title>
    <script type="text/javascript">
    function addBkGrnd(){
        document.myquiz.a1c.style.backgroundImage="url('test.jpg')";
    }
    </script>
    <style type="text/css">
    
    </style>
    </head>
    <body>
    <form name="myquiz" action=""><p>
    <input type="text" name="a1c">
    <input type="button" onclick="addBkGrnd();">
    </P></form>
    </body>
    </html>
    Last edited by DaveyErwin; 09-12-2011 at 08:29 PM.

  • Users who have thanked DaveyErwin for this post:

    lm111 (09-12-2011)

  • #4
    New Coder
    Join Date
    Sep 2011
    Posts
    25
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Thank you. Now what if I wanted to add some text after the image. How would I do that? Thanks.

  • #5
    Regular Coder
    Join Date
    Aug 2010
    Posts
    974
    Thanks
    19
    Thanked 212 Times in 210 Posts
    Quote Originally Posted by lm111 View Post
    Thank you. Now what if I wanted to add some text after the image. How would I do that? Thanks.
    The same way youadded it before ...
    document.myquiz.a1c.value = "CORRECT!";

    depending on exactly your image
    it will go on top of image
    with a added spaces and the
    right image and a no-repeat css
    it can be before or after image

  • #6
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,688
    Thanks
    80
    Thanked 4,655 Times in 4,617 Posts
    You could also simply do
    Code:
    <form name="myquiz" action="">
    <div id="a1c" style="visibility: hidden;">
        <img src="OhGoody.jpg" style="float: left;">CONGRATULATIONS!
    </div>
    <input type="button" 
           onclick="document.getElementById('a1c').style.visibility='visible';">
    </form>
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #7
    New Coder
    Join Date
    Sep 2011
    Posts
    25
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Thank you. One other question. How can I make the input box multiline, the text does not wrap? Any idea? thank you

    <INPUT type="text" style="BORDER-LEFT-COLOR: #ffffff; BORDER-BOTTOM-COLOR: #ffffff; COLOR: #808080; BORDER-TOP-STYLE: solid; BORDER-TOP-COLOR: #ffffff; BORDER-RIGHT-STYLE: solid; BORDER-LEFT-STYLE: solid; BORDER-RIGHT-COLOR: #ffffff; BORDER-BOTTOM-STYLE: solid; color:red; background-repeat:no-repeat; font-size:14px; width:100%;" name=a1c />

  • #8
    Senior Coder Rowsdower!'s Avatar
    Join Date
    Oct 2008
    Location
    Some say it's everything.
    Posts
    2,027
    Thanks
    5
    Thanked 397 Times in 390 Posts
    Use a textarea element rather than an input element and the text wrapping will be what you expect.
    The object of opening the mind, as of opening the mouth, is to shut it again on something solid. –G.K. Chesterton
    See Mediocrity in its Infancy
    It's usually a good idea to start out with this at the VERY TOP of your CSS: * {border:0;margin:0;padding:0;}
    Seek and you shall find... basically:
    validate your markup | view your page cross-browser/cross-platform | free web tutorials | free hosting

  • Users who have thanked Rowsdower! for this post:

    lm111 (09-13-2011)

  • #9
    New Coder
    Join Date
    Sep 2011
    Posts
    25
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Thank you !!!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •