0

Ok i am starting to think Jquery and AMPscript do not go with each other on the same page.

  1. I have an email with a button and i am passing a few url parameters to a Cloud page.
  2. I RequestParameter to populate these parameters onto an html form. (cloud page) This part works.
  3. I have jquery in this cloud page form to populate an element depending on the choice made.
  4. When the form is submitted, Customers will be directed to another Cloud page in MC and i want the values of this form to be passed to a DE when this happens.
  5. I am using UpsertData in the cloud page to pass the values but it doesn't seem to work.
  6. The form submits and i am directed to the desired cloud page but the values don't pass.
  7. The destination DE have all fields nullable and data types are all correct. No PK.
  8. I do not want to use Smart Capture.

Below is my Cloud page code. (SOLVED & WORKS)

  • I removed the formSubmit(event) javascript and applied the tag around the submit.
  • I passed a hidden tag with value for %%=v(@Email)=%%.
  • As much as i would have liked, Upsertdata does not work so i removed PK and made all fields Nullable.
%%[
set @Ename = RequestParameter('Ename')
set @Punit = RequestParameter('Punit')
set @Email = RequestParameter('Email')
]%%

<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous">
</script>

<form action="http://cloud.email-novaenergy.co.nz/confirmation" method="post">
<ul class="form-style-1">

<li>
<label>Name<span class=""></span></label>
<input type="text" name="Name" required="" value="%%=v(@Ename)=%%" class="field-dd" placeholder="">
</li>
             
</ul>

<ul class="form-style-1">

<span class="caption">Insert Question 1 here*</span><br>
<p style="margin:0 0 0 0;"><small>What does it mean </small><span onclick="$('.userinfo1').toggle();" style="cursor:pointer;">ⓘ</span><br>
<span class="userinfo1" style="display:none;"><small>example</small></span></p><br>

<input type="radio" name="Question1" value="customer1" onchange="$('.customer1').hide();$('.'+$(this).val()).toggle();">Yes
<input type="radio" name="Question1" value="" onchange="$('.customer1').hide();">No<br><br>

<div class="customer1" style="display:none;">
<span class="caption">Insert Question 1A here*</span><br>
<p style="margin:0 0 0 0;"><small>Helper </small><span onclick="$('.userinfo').toggle();" style="cursor:pointer;">ⓘ</span><br>
<span class="userinfo" style="display:none;"><small>Insert description here</small></span></p><br>
  
<input type="radio" name="Question1A" value="Standard User">Plan A
<input type="radio" name="Question1A" value="Low User">Plan B
</div><br>

<li>
<label>Date of birth*</label><br>
<input type="date" name="DOB" class="field">
</li><br>

<li>
<label>Unit</label><br>
<input type="text" name="Unit" value="%%=v(@Punit)=%%" class="field-divided" placeholder="Unit">
</li><br>
  
 <input type="hidden" name="email" value="%%=v(@Email)=%%">
  <a href="http://cloud.email-novaenergy.co.nz/confirmation">
<input id="submitted" type="hidden" name="submitted" value="submitted">
<input type="submit" value="Submit"></a>


</ul></form>

Below is the Handler form

%%[

set @ename = RequestParameter('Name')
set @Q1 = RequestParameter('Question1')
set @Q1A = RequestParameter('Question1A')
set @date = RequestParameter('date')
set @unit = RequestParameter('Unit')
set @Email = RequestParameter('email')


if RequestParameter("submitted") == "submitted" then
InsertDE("Testing_NC1","elec_name",@ename,"unit",@unit, "Q1", @Q1, "Q1A", @Q1A, "DOB", @date,"Email",@Email)
ENDIF 
]%%
2
  • 1
    Please try it with the InsertData function - your DE has no primary key, which UpsertData requires May 31 at 6:04
  • 1
    AMPScript gets executed before the other elements in the page like HTML, CSS or Javascript. Therefore, the client-side JS and AMPScript execute in a different context. However, you could try to post on the same page by changing your <form action=%%=RequestParameter('PAGEURL')=%%. Also as mentioned above comment switch to InsertData if you don't have a primary key in the DE. Let us know how it goes. May 31 at 6:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.