"Eric Johnston" <nospam@redyonder.co.uk> wrote in message
news:AlxCe.146147$Vo6.64655@fe3.news.blueyonder.co .uk...[color=blue]
>I want the visitor to enter three numbers on the page and then click a
>button "generate image" which will I hope cause a generated gif image
>to be displayed alongside on the page.
>
> This involved a php page elsewhere which does all the computing of the
> gif image. I can make this work successfully by using a static call
> like:
> <img src="test12.php?a=15&b=65&c=33000" width="200" height="200">
>
> How do I write javascript to allow the visitor to enter 3 numbers and,
> when ready, click a button to send a request to calculate
> test12.php?a=15&b=65&c=33000 and display the new gif on the same page,
> ideally with the option to edits the numbers and click again for
> different image ?[/color]
<img src="blank.gif" name="myImage" width="200" height="200">
<form name="myForm" action="post" onsubmit="return false;">
<input type="text" name="a">
<input type="text" name="b">
<input type="text" name="c">
<input type="button" name="btn" value="Update image"
onclick="updateImage(this.form);">
<script type="text/javascript">
function updateImage(f)
{
var img;
if (f && (f = f.elements) &&
(img = document.images) &&
(img = img['myImage'])
{
img.src = 'test.php' +
'?a=' + f['a'].value +
'&b=' + f['b'].value +
'&c=' + f['c'].value;
}
}
</script>
</form>
Then test.php would use ImageMagick to do something like the following.
This is a shell script, but you could either get PHPMagick, or shell out
from PHP to invoke 'convert':
#!/usr/bin/sh
echo "Content-type: image/gif"
echo ""
# retrieve the values of a, b and c from
# $QUERY and calculate the $answer
/usr/local/bin/convert \
-background '#000000FF' -fill '#0000000' \
-pointsize 12 label:"$answer" \
gif:-
--
Grant Wagner <gwagner@agricoreunited.com>
comp.lang.javascript FAQ -
http://jibbering.com/faq