...

View Full Version : please help



lm111
09-12-2011, 06:39 PM
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

devnull69
09-12-2011, 06:52 PM
Edit: facepalm

DaveyErwin
09-12-2011, 07:06 PM
<!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>

lm111
09-12-2011, 08:04 PM
Thank you. Now what if I wanted to add some text after the image. How would I do that? Thanks.

DaveyErwin
09-12-2011, 08:50 PM
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

Old Pedant
09-12-2011, 08:57 PM
You could also simply do


<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>

lm111
09-13-2011, 03:45 PM
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 />

Rowsdower!
09-13-2011, 03:47 PM
Use a textarea element rather than an input element and the text wrapping will be what you expect.

lm111
09-13-2011, 04:01 PM
Thank you !!!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum