Webpage data not transfering to schema after function change

Avatar

Avatar
Validate 1
Level 1
bryceh57660644
Level 1

Like

1 like

Total Posts

16 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 1
bryceh57660644
Level 1

Like

1 like

Total Posts

16 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile
bryceh57660644
Level 1

04-06-2020

After someone hits submit on a form, i am getting two rows of data.  Both have the same values for the manual inputs (email, name, etc), but for my checkboxes I am getting different values.  On the first value, it shows all three values as not interetested/"0", and then the second row will show their actual inputs.  Any idea why this is happening?

 

function next() {
var valid = validateForm()
if (valid == true) {
document.controller.submit('next','_self','next');
} else {

alert("Error");

}

if(document.getElementById('control_VC').checked){
document.controller.setValue('/ctx/vars/virtualcare',"0");
} else{
document.controller.setValue('/ctx/vars/virtualcare',"1");
}
if(document.getElementById('control_OB').checked){
document.controller.setValue('/ctx/vars/onlinebooking',"0");
} else{
document.controller.setValue('/ctx/vars/onlinebooking',"1");
}
if(document.getElementById('control_LHP').checked){
document.controller.setValue('/ctx/vars/profile',"0");
} else{
document.controller.setValue('/ctx/vars/profile',"1");
}
}

 

I also then added an alert if my email value was not filled out, and now the values are showing in the debug mode of the web page, but the values are not transferring to the data schema like they were when function validateForm()  was set to only "return true;"

 

function setDefaultValue() {
document.getElementById("control_EMAIL").value = null;
}
function updateEmail(email) {
document.controller.setValue('/ctx/vars/email', email);
document.getElementById("control_EMAIL").value = "Ok";
}

function validateForm() {
var email = document.getElementById("control_EMAIL").value
if (email == null) {
alert("Alert");
}
else {
return true;
}
}

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Boost 50
MVP
Jyoti_Y
MVP

Likes

88 likes

Total Posts

123 posts

Correct reply

55 solutions
Top badges earned
Boost 50
Shape 1
Boost 5
Give Back 5
Give Back 3
View profile

Avatar
Boost 50
MVP
Jyoti_Y
MVP

Likes

88 likes

Total Posts

123 posts

Correct reply

55 solutions
Top badges earned
Boost 50
Shape 1
Boost 5
Give Back 5
Give Back 3
View profile
Jyoti_Y
MVP

04-06-2020

Hi,

 

Your function validateForm(), returns value only when email value is not null.

So there's two loop happening:

1) If email value is not null, script is going to next page and inserting data.

2) If email value is null, your function returns nothing, so script goes to else part and never goes to next page of storage. 

That's why values are not inserted.

 

For your question related to two data value insert, I would suggets to place your if else check before submitting to next page, i.e:

if (valid == true) {

//Add your if else logic here

document.controller.submit('next','_self','next');

 

Thanks.

Answers (1)

Answers (1)

Avatar

Avatar
Affirm 100
MVP
_Manoj_Kumar
MVP

Likes

117 likes

Total Posts

329 posts

Correct reply

102 solutions
Top badges earned
Affirm 100
Validate 1
Contributor
Ignite 1
Shape 1
View profile

Avatar
Affirm 100
MVP
_Manoj_Kumar
MVP

Likes

117 likes

Total Posts

329 posts

Correct reply

102 solutions
Top badges earned
Affirm 100
Validate 1
Contributor
Ignite 1
Shape 1
View profile
_Manoj_Kumar
MVP

04-06-2020

Hello @bryceh57660644 ,
could you please share the input field screenshot and the javascript part.

If by clicking on the submit button you can see the updated variables in debug mode.

Then you can add this line after setting variables to redirecting to next javascript activity.

document.controller.submit('next');

 

let me knw if that helps.