Skip to main content

I have a form that has two drop down menus in it and I would like to have the second drop down menu only be populated with values that are relevant to what the user selected within the first drop down menu. I have the value they choose in the first drop down assigned to a JavaScript variable but, unsure of how to convert it into a AMPScript variable.

1 answer
  1. Oct 27, 2022, 5:09 PM

    Yes, there are core and platform functions to convert SSJS variables to AMPscript variables.

    Variable.SetValue("@AmpVar", jsVar)

    This is the Core function, if your value is stored in the JS variables jsVar, this will set the AMPscript variable @AmpVar to that value. 

     

    I'm not sure if this is exactly what you are meaning, or if you are talking about using client side JS here to kind of have a dependent picklist. 

    If that's the case, you just use your client side JS to do that, present the right inputs with different names and values, and submit them with your form. Then you can get those values on the submit page with the AMPscript QueryParameter function like this.

    SET @AmpVar = QueryParameter("form_input_name")