467,075 Members | 964 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,075 developers. It's quick & easy.

Help please with inputting and then passing parameters

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 ?

Best regards, Eric.
Jul 23 '05 #1
  • viewed: 1380
Share:
6 Replies
Lee
Eric Johnston said:

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 ?


You don't really want to use Javascript for that. You want to learn
about form processing in PHP. This isn't the correct newsgroup for that.

Jul 23 '05 #2

So, what do you need, data validation or...? I mean, you didn't quite
state your question, you need 3 numbers? use a Form and field elements,
plain HTML.

Danny


--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Jul 23 '05 #3
Lee wrote:
Eric Johnston said:

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 involves 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 edit the numbers and click again
for different image ?


You don't really want to use Javascript for that. You want to learn
about form processing in PHP. This isn't the correct newsgroup for
that.


Many thanks Danny and Lee

I am not attempting validation at this stage.
I have just made an html form and elements. The three numbers come in OK
( I can multiply them etc and display a total for example) but can't output
the three number variables as url link parameters:
This does not work:
document.write('<img
src="test12.php?a=form.a.value&b=form.b.value&b=fo rm.c.value" width="200"
height="200"></td>');
It just sends out the text names of the variables like
"test12.php?a=form.a.value etc", even when form.a.value=15

On the other hand this static experiment does work
//document.write('<img src="test12.php?a=15&b=25&c=33000" width="200"
height="200"></td>');
Unfortunately this deletes the existing browser page creates a blank brower
page with the new gif instead of putting the gif into the existing page.
Solving that will be the next problem after I've got the variables going
into the parameters.

Is it possible to avoid javascript ? Does some html command allow you to
put form variables on the end of a url link that will call a gif?

I've tried doing html form method=post and can successfully transfer all the
variables to the php page and process the data in the php, but the result is
to give control to the php page rather than simply getting the php page to
return only a gif file. I want the new gif to appear back on the original
page alongside the 3 input numbers to give the visitor a chance to review
the image and try other numbers.

At the moment I have two pages. An html page (with embedded javascript, if
needed) that displays the input number boxes and a php page that takes in
three numbers and return a gif. I want the gif back on the html input page
ready for another go. If my concept is wrong please say.

Best regards, Eric.
Jul 23 '05 #4
Lee
Eric Johnston said:

Lee wrote:
Eric Johnston said:

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 involves 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 edit the numbers and click again
for different image ?
You don't really want to use Javascript for that. You want to learn
about form processing in PHP. This isn't the correct newsgroup for
that.


Many thanks Danny and Lee

At the moment I have two pages. An html page (with embedded javascript, if
needed) that displays the input number boxes and a php page that takes in
three numbers and return a gif. I want the gif back on the html input page
ready for another go. If my concept is wrong please say.


Your form should have the ACTION attribute set to the URL of
your PHP page. The PHP page can then receive the values directly
from the form, instead of from the URL. That's what PHP form
processing is all about.

Jul 23 '05 #5
Lee wrote:
Eric Johnston said:

Lee wrote:
Eric Johnston said:

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 involves 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 edit the numbers and click again
for different image ?

You don't really want to use Javascript for that. You want to learn
about form processing in PHP. This isn't the correct newsgroup for
that.


Many thanks Danny and Lee

At the moment I have two pages. An html page (with embedded
javascript, if needed) that displays the input number boxes and a
php page that takes in three numbers and return a gif. I want the
gif back on the html input page ready for another go. If my concept
is wrong please say.


Your form should have the ACTION attribute set to the URL of
your PHP page. The PHP page can then receive the values directly
from the form, instead of from the URL. That's what PHP form
processing is all about.


Yes, I have made the html action work OK, but doing that gives control to
the php page and I was wanting the php page to return only the gif which
would display itself in the original html page. If it is not possible to do
what I suggest with javascript I may try to use one big php page that keeps
reproducing itself each time the visitor enters new variables.

Thanks, Eric.
Jul 23 '05 #6
"Eric Johnston" <no****@redyonder.co.uk> wrote in message
news:Al********************@fe3.news.blueyonder.co .uk...
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 ?


<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 <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

By using this site, you agree to our Privacy Policy and Terms of Use.