j/k
passing variables back to same original page?
Moderator: General Moderators
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
ok i edited that code snipet you gave on forum page 1 of this topic
when i used the name of my html file in here
it gave= (HTTP 403 Forbidden) The website declined to show this webpage.
what is 'basename'? is there somethingIm missing there
any suggestions, since i never made any special security or access passwords etc to it?
when i used the name of my html file in here
Code: Select all
<form name="formx" method="post" action="<?php echo basename(test_calculator.html); ?>">what is 'basename'? is there somethingIm missing there
any suggestions, since i never made any special security or access passwords etc to it?
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Again, I was using pseudo-code. Basically you would declare the value that you want displayed in the input as blank. Once the value is calculated, you reassign the calculated value into the previously declared variable. That way you can always be confident that echoing the variable will echo the right value.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
ok i tried that, switched .html to .php page.
it reloads the page, but doesnt keep the variables, the select menu defaults back to 'please select' state lol
I think all I'm doing is slaughtering my former coding that worked in javascript. l o l
this sucks.
oh boy, anyway , check this out
------------------------
it doesnt look right but if this helps you know what im 'trying' to do
desription:
a = name of select menu 1
b = name of select menu 2
c = name of select menu 3
d = name of select menu 4
e = name of subtotal <input> text box
f= name of select menu 5
g = name of select menu 6
it reloads the page, but doesnt keep the variables, the select menu defaults back to 'please select' state lol
I think all I'm doing is slaughtering my former coding that worked in javascript. l o l
this sucks.
oh boy, anyway , check this out
Code: Select all
<?php
$input_value = '';
if (!empty($_POST['value']))
{
e = (a*b) + (a*c) + (a*d) + (a*f) + g; // Calculate.
e = number_format ($total, 2);
$input_value = $calculation; // This would have been handled by the math
}
?>------------------------
it doesnt look right but if this helps you know what im 'trying' to do
desription:
a = name of select menu 1
b = name of select menu 2
c = name of select menu 3
d = name of select menu 4
e = name of subtotal <input> text box
f= name of select menu 5
g = name of select menu 6
Last edited by revocause on Tue May 29, 2007 1:12 pm, edited 2 times in total.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
the above was the php script
heres the example select menu , there are 6 of them
with different values, and names a through g ( except 'e' is a subtotal <input>)
This is the last select menu that will trigger the process .
and here is the input subtotal text box
heres the example select menu , there are 6 of them
with different values, and names a through g ( except 'e' is a subtotal <input>)
Code: Select all
<select name="a" STYLE="width: 110 px">
<option selected="selected" value="">Please Select</option>
<option value="100">100</option>
<option value="500">500</option>
<option value="1,000">1,000</option>
<option value="2000">2,000</option>
<option value="3000">3,000</option>
<option value="4000">4,000</option>
<option value="5000">5,000</option>
<option value="10000">10,000</option>
</select>Code: Select all
<select name="g" STYLE="width: 110 px" onChange="submit(this.formx)">
<option selected="selected" value="">Please Select</option>
<option value="0">1</option>
<option value="60">2</option>
</select>Code: Select all
<input type="number" readonly value="" name="anssubtotal" size=5 value="<?php echo $input_value; ?>" />what looks odd and confusing to me, is that in the php script
im using the names of the select menus
example
e = (a*b) + (a*c) + (a*d) + (a*f) + g; // Calculate.
but will i have to make them into $variables first?
like $a = a
$b = b
$c = c
etc
and then use that math function?
Right now that code of the top php script (a couple posts ago) isnt finished, as you can tell its a scattered mess in the works
of javascript being converted to php functions.
but I want to know what im doin compared to what i was doin , thats why it looks to FUBAR
im using the names of the select menus
example
e = (a*b) + (a*c) + (a*d) + (a*f) + g; // Calculate.
but will i have to make them into $variables first?
like $a = a
$b = b
$c = c
etc
and then use that math function?
Right now that code of the top php script (a couple posts ago) isnt finished, as you can tell its a scattered mess in the works
of javascript being converted to php functions.
but I want to know what im doin compared to what i was doin , thats why it looks to FUBAR
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Everah,
I'd pay you to write what Im tryin to do .
because farting around with it , is a waste of time, but seeing it done the right way once, and then I'd know and never forget it.
its like one of them things you need to see it, to read the code and understand = "ahhh ha"
otherwise this is all like cerebral oatmeal
(Vader = "you will tell me what you've done..with that code"
I'd pay you to write what Im tryin to do .
because farting around with it , is a waste of time, but seeing it done the right way once, and then I'd know and never forget it.
its like one of them things you need to see it, to read the code and understand = "ahhh ha"
otherwise this is all like cerebral oatmeal
(Vader = "you will tell me what you've done..with that code"
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
Check out the PHP section at W3Schools and look at PHP Forms and PHP $_POST. It has some sample code and should somewhat clarify the way posted variables work.
I thought this forum was about getting help?
I feel like Im bringing the stick back..and somebody tosses it away again for me to run after it again .
its a line of code, if somebody had asked me , I would see their code was screwed, and write it out once, then erase it off the board
but at least let me see what it should look like, this cat and mouse scenario of tutoring is kinda strange.
I know how to code basic php , i just cant get this thing. so this trial and error cat and mouse is ass chafing
I feel like Im bringing the stick back..and somebody tosses it away again for me to run after it again .
its a line of code, if somebody had asked me , I would see their code was screwed, and write it out once, then erase it off the board
but at least let me see what it should look like, this cat and mouse scenario of tutoring is kinda strange.
I know how to code basic php , i just cant get this thing. so this trial and error cat and mouse is ass chafing
Last edited by revocause on Tue May 29, 2007 1:54 pm, edited 1 time in total.