registering
07-14-2003, 10:54 PM
Hello all,
I'm new to both javascript and PHP and am having trouble seeing the "big
picture". I thought I had it down but I added some javascript and am now
lost conceptually.
I'm building menus dynamically via javascript, and would like to pass on
the current values of these menus to a PHP script which creates an image
for me (a graph of the values).
Normally I would do something like this:
<form action="graph1.php?$query_string" name=form7 method=post>
<input type="submit" value="Send form">
</form>
which works fine when the page is first loaded ($query_string is given
default values). However the intent is for the user to change the menus'
values, hit "submit" again and the image will be recreated.
How do I do that so the image is recreated in the correct place when the
user hits the "submit" button or changes a menu selection? That is, I can
do something like this:
<form action="stacked.php" name=form7 method=post onSubmit="return false;">
<select name="Table" onchange="CallGraph()">
<option selected=true value="spacekeeper">Table</option>
</select>
</form>
so that when the user changes a selection, "CallGraph()" is called which
is a javascript function that builds the $query_string to pass to graph1.php.
However I'm lost as to what to do next. How do I simply call graph1.php from
within CallGraph() so that the image will appear in the proper place??
If there was a way I could "reload" the page without $query_string being
initialized to its default values, but rather take the menus values, that's
probably best, however I don't know how to do that. Since the menus only get
changed via javascript, the PHP code has already finished executing, which is
why I thought I could tie a button to call graph1.php explicitly, but I'm not
sure how best to do that.
You can view the code at www.mindspring.com/~jc416975/stacked.html for reference
or www.mindspring.com/~jc416975/stacked.php (although it won't execute). Other
applications this script depends on aren't running currently so you get errors
if you hit the actual button).
Thanks for any pointers, it's greatly appreciated.
I'm new to both javascript and PHP and am having trouble seeing the "big
picture". I thought I had it down but I added some javascript and am now
lost conceptually.
I'm building menus dynamically via javascript, and would like to pass on
the current values of these menus to a PHP script which creates an image
for me (a graph of the values).
Normally I would do something like this:
<form action="graph1.php?$query_string" name=form7 method=post>
<input type="submit" value="Send form">
</form>
which works fine when the page is first loaded ($query_string is given
default values). However the intent is for the user to change the menus'
values, hit "submit" again and the image will be recreated.
How do I do that so the image is recreated in the correct place when the
user hits the "submit" button or changes a menu selection? That is, I can
do something like this:
<form action="stacked.php" name=form7 method=post onSubmit="return false;">
<select name="Table" onchange="CallGraph()">
<option selected=true value="spacekeeper">Table</option>
</select>
</form>
so that when the user changes a selection, "CallGraph()" is called which
is a javascript function that builds the $query_string to pass to graph1.php.
However I'm lost as to what to do next. How do I simply call graph1.php from
within CallGraph() so that the image will appear in the proper place??
If there was a way I could "reload" the page without $query_string being
initialized to its default values, but rather take the menus values, that's
probably best, however I don't know how to do that. Since the menus only get
changed via javascript, the PHP code has already finished executing, which is
why I thought I could tie a button to call graph1.php explicitly, but I'm not
sure how best to do that.
You can view the code at www.mindspring.com/~jc416975/stacked.html for reference
or www.mindspring.com/~jc416975/stacked.php (although it won't execute). Other
applications this script depends on aren't running currently so you get errors
if you hit the actual button).
Thanks for any pointers, it's greatly appreciated.