Trying to POST data from a "repeating" form field
Moderator: General Moderators
Trying to POST data from a "repeating" form field
Could someone give a an idea why this form doesn't POST the variable prod_id_index properly?
<form name="form1" method="post" action="j_cart/j_confirm_add.php">
<input name="hiddenField" type="hidden" value="<?php echo $row_rs_kb_prod['prod_id_index']; ?>">
<a href="javascript:;" onclick="formButtonFever('form1','submit')"><img src="../images/e_add_to_kart.gif" width="105" height="48" border="0"></a>
Some background on this... I've intended for the button to appear on every row in a DO WHILE search results situation.
I don't know how it is done, so I keep reading things and getting ideas to try. This one makes the most sense, but doesn't pass anything to the receiving page. The variable prod_id_index is contained in the hidden field that the button submits, and is different for each displayed row.
Any insight appreciated.
------------------------
SteedVLX
<form name="form1" method="post" action="j_cart/j_confirm_add.php">
<input name="hiddenField" type="hidden" value="<?php echo $row_rs_kb_prod['prod_id_index']; ?>">
<a href="javascript:;" onclick="formButtonFever('form1','submit')"><img src="../images/e_add_to_kart.gif" width="105" height="48" border="0"></a>
Some background on this... I've intended for the button to appear on every row in a DO WHILE search results situation.
I don't know how it is done, so I keep reading things and getting ideas to try. This one makes the most sense, but doesn't pass anything to the receiving page. The variable prod_id_index is contained in the hidden field that the button submits, and is different for each displayed row.
Any insight appreciated.
------------------------
SteedVLX
This would give you the variable $_POST['hiddenField'];
Maybe what you're after is:
Maybe what you're after is:
Code: Select all
<input name="prod_index_id" type="hidden" value="<?php echo $row_rs_kb_prodї'prod_id_index']; ?>">Thanks for the tip, however something else is amiss. This HTML/PHP code....
Now outputs this HTML source code for the displayed page...
As you can see, I have rigged it where each data row has a form with a unique name. Now, that name is the part number from the data row. The form name, and all the form values are filled dynamically now. Everything on the catalog view page displays fine. But, alas, I cannot actually get the ACTION page to come up when I click on the add_to_kart (submit) button.
Please help, I'm Lost lost lost.
-----------------------
SteedVLX
Code: Select all
<form name="<?php echo $row_rs_kb_prodї'prod_kb_part_num'];?>" method="post" action="j_cart/j_confirm_add.php">
<input name="prod_number" type="hidden" id="prod_number" value="<?php echo $row_rs_kb_prodї'prod_kb_part_num']; ?>">
<a href="javascript:;" onclick="formButtonFever('<?php echo $row_rs_kb_prodї'prod_kb_part_num'];?>','submit')"><img src="../images/j_add_to_kart.gif" width="105" height="48" border="0"></a>
</form>Code: Select all
<form name="101-111-1237" method="post" action="j_cart/j_confirm_add.php">
<input name="prod_number" type="hidden" id="prod_number" value="101-111-1237">
<a href="javascript:;" onclick="formButtonFever('101-111-1237','submit')"><img src="../images/j_add_to_kart.gif" width="105" height="48" border="0"></a>
</form>Please help, I'm Lost lost lost.
-----------------------
SteedVLX
just a thought...why not use this.form?
Code: Select all
onclick="formButtonFever(this.form,'submit')releasedj,
Well, I tried that too. Now the resulting HTML is...
it passes diagnostics, but still no resulting page...
corlando,
I've never seen that before. If you mean literally putting "this.form" in the form name area, then I'll try it and see what happens.
Thanks for the 'eyes'
------------------------
SteedVLX
Well, I tried that too. Now the resulting HTML is...
Code: Select all
<form action="j_cart/j_confirm_add.php" method="post" name="part101-111-1237">
<input name="prod_number" type="hidden" id="prod_number" value="101-111-1237">
<a href="javascript:;" onclick="formButtonFever('101-111-1237','submit')"><img src="../images/j_add_to_kart.gif" width="105" height="48" border="0"></a>
</form>corlando,
I've never seen that before. If you mean literally putting "this.form" in the form name area, then I'll try it and see what happens.
Thanks for the 'eyes'
------------------------
SteedVLX
I'll try and give you a better idea into a way of doing this.
It's really quite simple when you get the hang of it:
Before you do the loop, output a form at the top of the page, with the javascript used to submit the form:
then in your loop, do this:
That should do it, or should be pretty close anyway.
Kelvin
It's really quite simple when you get the hang of it:
Before you do the loop, output a form at the top of the page, with the javascript used to submit the form:
Code: Select all
<form action="j_cart/j_confirm_add.php" method="post" name="part_form">
<input type="hidden" name="prod_number" value="">
</form>
<script language="JavaScript" type="text/javascript">
<!--
function formButtonFever (partno)
{
var f = document.part_form;
f.prod_number.value = partno;
f.submit();
}
-->
</script>Code: Select all
<a href="javascript:;" onclick="formButtonFever('<?php echo $row_rs_kb_prod['prod_kb_part_num']; ?>')"><img src="../images/j_add_to_kart.gif" width="105" height="48" border="0"></a>Kelvin
releasedj,
That looks pretty interesting. I've never studied javascript and have always used packaged stuff. I'll try it first thing tomorrow and see if I can get that to work.
I have found that formbuttonfever is the problem... I've never had a problem with that script, but it is somehow broken by something in the code.
I ripped it out and used the generic (read:hideous) button calls and guess what. The rest of the code works.
I never suspected the formbuttonfever script because every button I have on my site thus far uses this script and works great.
Thank you for taking the time to show me the java. I appreciate it and i'll try to understand and implement. If I can't my entire theme is going to be destroyed by those ugly default buttons.
If you or anybody else knows of a good way to use any image I want as a button, I would be grateful to learn that as well.
Well it's 2;00am in my part of Asia...Good nite all!
---------------------
SteedVLX
That looks pretty interesting. I've never studied javascript and have always used packaged stuff. I'll try it first thing tomorrow and see if I can get that to work.
I have found that formbuttonfever is the problem... I've never had a problem with that script, but it is somehow broken by something in the code.
I ripped it out and used the generic (read:hideous) button calls and guess what. The rest of the code works.
Code: Select all
<form action="<?php echo "j_cart/j_confirm_add.php";?>" method="post" name="<?php echo "part" . $row_rs_kb_prodї'prod_kb_part_num'];?>">
<input name="prod_number" type="hidden" id="prod_number" value="<?php echo $row_rs_kb_prodї'prod_kb_part_num'];?>">
<input type="submit" name="Submit" value="Add to Cart">
</form>Thank you for taking the time to show me the java. I appreciate it and i'll try to understand and implement. If I can't my entire theme is going to be destroyed by those ugly default buttons.
If you or anybody else knows of a good way to use any image I want as a button, I would be grateful to learn that as well.
Well it's 2;00am in my part of Asia...Good nite all!
---------------------
SteedVLX
One thing that might help.. When yo renamed the form, you didn't change the call to formButtonFever(). You should have changed that as well.
On another tip, I'm not sure whether you can have form names that include the '-' character. If you do the above and that doesn't work, try replacing '-'
with '_' (underscores).
Kelvin
On another tip, I'm not sure whether you can have form names that include the '-' character. If you do the above and that doesn't work, try replacing '-'
with '_' (underscores).
Kelvin
releasedj, have you ever thought about using this tag?
Code: Select all
<input type="image" name="submit" src="../images/j_add_to_kart.gif" width="105" height="48" border="0">Yes, this would also be a good method. You don't really need the name attribute either, and so you wouldn't get the x and y variables sent.
Upon reflection, this is probably the method to use for this problem.
It does seem a bit futile to have to have a different form for each item, but I guess that doesn't cause much of a problem.
Upon reflection, this is probably the method to use for this problem.
It does seem a bit futile to have to have a different form for each item, but I guess that doesn't cause much of a problem.
Problem Solved (kinda)
The final code looks like this if anyone is interested. I even got the popup confirmation window to work right.
Thanks for the direction everyong. That was tough for a newbie.
------------------
SteedVLX
The final code looks like this if anyone is interested. I even got the popup confirmation window to work right.
Code: Select all
<form name="<?php echo "id_" . $row_rs_kb_prodї'prod_id_index'];?>" method="get" action="javascript:; "onClick="OpenBrWindow('j_confirm_add.php?prod_id_index=<?php echo $row_rs_kb_prodї'prod_id_index']?>','cartpop1','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no','610','290','true')"></a>
<input name="prod_id_index" type="hidden" id="prod_id_index" value="<?php echo $row_rs_kb_prodї'prod_id_index']; ?>">
<input name="Submit" type="image" value="Add to Cart" src="../images/j_add_to_kart.gif" align="absmiddle">
</form>------------------
SteedVLX