Question about how to populate a chronoform hidden field

Grumpster 29 Dec, 2009
I'm trying to send a field value to a multiple choice Paypal buy now button page, but I cannot figure out how to do it.

My Chronoform field value is from a set of four radio buttons with name="agegroup" and I want that field's value to go into Paypal's name="item_name" field.

The problem is, I have already used the Chronoform's name="agegroup" radio button field value to populate the "os0" field on the Paypal form since that's how you tell the Paypal form which price level option to use.

So, I figured I would just create a hidden field with name="fee_description" in my Chronoform form and populate it with the value of whichever radio button was selected in the name="agegroup" radio button field. I could then pass the value of "fee_description" to the Paypal "item_name" field.

In my attempts to populate the hidden field, I've tried different bits of JavaScript and PHP code in the OnSubmit code box, but neither seem to be working at all. I can't even get a JavaScript alert box to work in the OnSubmit code box (can I even put JavaScript in that box?). Does the Redirect Plugin interfere with that box?

Should I only be putting code into the "Extra Code" box in the Redirect Plugin's settings to populate my form's hidden field? If so, should I use only PHP or JavaScript? Or does it matter?

Sorry for being such a dunce, but I've been chasing my tail for a few hours on this and I just need a wee bit of guidance as to where the best place to put the code should be.

I think I can figure out the PHP, Javascript, or even the JRequest code on my own, but I really need to know which code box to put this stuff into.

Oh, and if I'm completely over-thinking this, let me know. No doubt I'm overlooking a far simpler solution.
Grumpster 29 Dec, 2009
Not sure how I managed to miss this on my first umpteen forum searches for answers, but this post may have everything I need: PayPal Redirect Dropdown Values.

I'll report back once I try that approach.
GreyHead 29 Dec, 2009
Hi grumpster,

The post that you linked to looks like a pretty good guide.

As you will have seen you are probably best using the Plugin Extra Code box to set up these extra values.

You could use the same button field value to set the value of two fields in the plugin if you need to.

The boxes will all support JavaScript - but most of the time it won't do anything much; if you are using the ReDirect Plugin then the code from the OnSubmit boxes will be preocessed but nothing will be displayed in the browser because of the redirect.

Bob
Grumpster 29 Dec, 2009

You could use the same button field value to set the value of two fields in the plugin if you need to.



Is that something straightforward I can do with the redirect plugin? I tried simply setting the values in the field next to my "agegroup" field to "os0,item_name" but it gave me an error message on the Paypal page.

Or, were you talking about doing it with PHP or JavaScript?
Grumpster 29 Dec, 2009
GreyHead,

I finally got it to work using your code from your thread I originally referenced above.

Following your instructions, I created a hidden field and placed it at the bottom of the form code:

<input type='hidden' name='item_name' value='' />


Then I placed this in the "Extra before CURL code" field in the Redirect Plugin (inside the "Extra Code" tab).

    <?php
    $agegroup = JRequest::getString('agegroup', '', 'post');
    switch ( $agegroup ) {
      case '12 and Under':
      default:
        JRequest::setVar('item_name', '12 and Under Registration Fee', 'post');
        break;
      case '16 and Over':
        JRequest::setVar('item_name', '16 and Over Registration Fee', 'post');
        break;
    }
    ?>


Then, still in the Redirect Plugin, under the "General" tab, at the bottom of the list of field names was my new hidden field ('item_name' field). In the text input beside that, I typed "item_name" to link it to the Paypal field of that name.

Saved it. Tested it. It worked!

Many, many thanks to you, GreyHead.🙂
GreyHead 29 Dec, 2009
Hi Grumpster,

Well done. Glad you got it all working.

I got the two field thing backwards, sorry.

Bob

PS I do have a beta version where you can enter param_name={field_name} as well as param_name=value in the bigger box in the configuration - that would have done it for you I think.
This topic is locked and no more replies can be posted.