Rabel
asked on
Passing Multiple Values with a Drop Down list using javascript?
I am trying to replace a few textboxes and create a dropdown to replace it. I thought that I could do it by passing javascript through with three variables - replacing the text boxes. But this is not working it is telling me that I am not passing through an amount, which I am trying to pass through first.
in the head
function op1(amount,invoice_num,des cription)
{
return <? print $_REQUEST['amount']; print $_REQUEST['invoice_num']; print $_REQUEST['description'];? >;
}
in the body
<label>
<select name="select7" id="select7">
<option value="<script type='text/javascript'>doc ument.writ e(op1(12.0 0,100,no description));</script>">O ption One</option>
<option value="<script type='text/javascript'>doc ument.writ e(op1(24.0 0,101,no description));</script>" selected>Option Two</option>
<option value="<script type='text/javascript'>doc ument.writ e(op1(36.0 0,102,no description));</script>">O ption Three</option>
<option value="<script type='text/javascript'>doc ument.writ e(op1(48.0 0,103,no description));</script>">O ption Four</option>
<option value="<script type='text/javascript'>doc ument.writ e(op1(60.0 0,104,no description));</script>">O ption Five</option>
</select>
</label>
I am open to changing this anyway I can get it to work. Please let me know what im doing wrong.
Thanks,
Randy
in the head
function op1(amount,invoice_num,des
{
return <? print $_REQUEST['amount']; print $_REQUEST['invoice_num']; print $_REQUEST['description'];?
}
in the body
<label>
<select name="select7" id="select7">
<option value="<script type='text/javascript'>doc
<option value="<script type='text/javascript'>doc
<option value="<script type='text/javascript'>doc
<option value="<script type='text/javascript'>doc
<option value="<script type='text/javascript'>doc
</select>
</label>
I am open to changing this anyway I can get it to work. Please let me know what im doing wrong.
Thanks,
Randy
ASKER
Hi Hielo,
that is close but I need to pass the info to a cart so I need to name the variables - amount, invoice_num, description. Any Idea how I can do that. Thanks Again.
that is close but I need to pass the info to a cart so I need to name the variables - amount, invoice_num, description. Any Idea how I can do that. Thanks Again.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Great Hielo, that works perfect. I will add 100 points if you can explain to me how to get a unique number in the second spot for the invoice_num.
>>how to get a unique number in the second spot
Where are you getting your data from? I thought were were getting these
12.00,100,no description
...
60.00,104,no description
from some database and the invoice_num was an autonumber. So, if you ARE preloading it FROM a db, then you should have an autonumber field and use that as the field.
If you are NOT preloading it, but instead intend TO load/update the db based on the selection, the you should NOT be including that invoice_num in the web form because the invoice number would be auto-generated when you actually insert the record into your db.
If you are NOT using a db at all, then I strongly suggest you do.
Regards,
Hielo
Where are you getting your data from? I thought were were getting these
12.00,100,no description
...
60.00,104,no description
from some database and the invoice_num was an autonumber. So, if you ARE preloading it FROM a db, then you should have an autonumber field and use that as the field.
If you are NOT preloading it, but instead intend TO load/update the db based on the selection, the you should NOT be including that invoice_num in the web form because the invoice number would be auto-generated when you actually insert the record into your db.
If you are NOT using a db at all, then I strongly suggest you do.
Regards,
Hielo
ASKER
Thanks Heilo,
I am just using the basic merchant coding that they provided for this small project. I think we will probably only have 20-30 transactions on here. I set it up to use a random number for now.
var randomnumber=Math.floor(Ma th.random( )*100000)
Its not real pretty but I think it should work. What do you think.
This is the info from developer guide, if you can think of anything but you've done enough. I really appreciate your help Heilo.
FIELD NAME - invoice_num
REQUIRED? - Optional
VALUE - The merchant assigned invoice number for the transaction
FORMAT - Up to 20 characters (no symbols)
NOTES - The invoice number must be created dynamically on the merchant server or provided on a per-transaction basis. The payment gateway does not perform this function.
Thanks,
Randy
I am just using the basic merchant coding that they provided for this small project. I think we will probably only have 20-30 transactions on here. I set it up to use a random number for now.
var randomnumber=Math.floor(Ma
Its not real pretty but I think it should work. What do you think.
This is the info from developer guide, if you can think of anything but you've done enough. I really appreciate your help Heilo.
FIELD NAME - invoice_num
REQUIRED? - Optional
VALUE - The merchant assigned invoice number for the transaction
FORMAT - Up to 20 characters (no symbols)
NOTES - The invoice number must be created dynamically on the merchant server or provided on a per-transaction basis. The payment gateway does not perform this function.
Thanks,
Randy
function op1(amount,invoice_num,des
{
return <? print $_REQUEST['amount']; print $_REQUEST['invoice_num']; print $_REQUEST['description'];?
}
You are mixing SERVER code which runs BEFORE the browser code. So that is definitely causing problems.
Not sure if the attached code is what you actually intended.
Open in new window