Jump to content
Sign in to follow this  
Brasovan

Can't get Java to read variables

Recommended Posts

I would appreciate any help you can provide on the following:

I this java script on an input form where the parameter [@SU_Type] is passed into the page through a link.  THIS SCRIPT WORKS perfectly:

<h5><span id="business2" style="color:#263C87;">Company Information:</span></h5>
<script>
TypeC=[@SU_Type]

if(TypeC == 1) {document.getElementById("business2").style.display = "none"}

</script>

THE PROBLEM:

I'm trying to do something very similar on the email/destinations page of another form and it is NOT working.  In this form the parameters [@Mailing_Addr_Type] and [@Mailing_Check] are being used in the form and should then be passed, which I am assuming makes them available for use on the Destinations page.  However, no matter how I format them in the Jave on the Destinations page of the form the Java does not seem to read the values.  I have tested the java itself on other sites and it works if a Value is assigned to md directly.  What am I missing?  This is my latest iteration, treating the variables as values on the same form as the Java.  It does not work.  I have tried the following parameter formats:

[@field:Mailing_Addr_Type] (with and without the # at the end)

[@Mailing_Addr_Type]

Thanks for taking the time to look at this.

CODE THAT IS NOT WORKING (with fake link info):

<h4>Your submission was successful.</h4>

<p id="answ3">If you wish to enter additional addresses:</p>

<p id="answ2">It appears that the address you entered was not a mailing address (or was not marked as one). Please click the link below and enter a mailing address that can be used in the letter of authorization document. This is required by the utility, not us. Thank you.</p>
<button onclick="location.href='https://www.GOOGLE.COM/'" type="button">Add another address</button>

<p><span id="answ1">Or, if you are done entering addresses: </span></p>
<span id="answ4"><button onclick="location.href='https://www.GOOGLE.COM/'" type="button">Proceed to the Letter of Agreement</button></span><br />
<br />
<script>

A=document.getElementById("InsertRecordMailing_Addr_Type").value;
B=document.getElementById("InsertRecordMailing_Check").value;
md=A+B

if(md==0) { document.getElementById("answ1").style.display="none";
document.getElementById("answ3").style.display="none";
document.getElementById("answ4").style.display="none";
}
else { document.getElementById("answ2").style.display="none"; 
document.getElementById("InsertRecordMailing_Check").value=1;
}

</script>

 

Share this post


Link to post
Share on other sites
20 hours ago, Brasovan said:

I would appreciate any help you can provide on the following:

I this java script on an input form where the parameter [@SU_Type] is passed into the page through a link.  THIS SCRIPT WORKS perfectly:

<h5><span id="business2" style="color:#263C87;">Company Information:</span></h5>
<script>
TypeC=[@SU_Type]

if(TypeC == 1) {document.getElementById("business2").style.display = "none"}

</script>

THE PROBLEM:

I'm trying to do something very similar on the email/destinations page of another form and it is NOT working.  In this form the parameters [@Mailing_Addr_Type] and [@Mailing_Check] are being used in the form and should then be passed, which I am assuming makes them available for use on the Destinations page.  However, no matter how I format them in the Jave on the Destinations page of the form the Java does not seem to read the values.  I have tested the java itself on other sites and it works if a Value is assigned to md directly.  What am I missing?  This is my latest iteration, treating the variables as values on the same form as the Java.  It does not work.  I have tried the following parameter formats:

[@field:Mailing_Addr_Type] (with and without the # at the end)

[@Mailing_Addr_Type]

Thanks for taking the time to look at this.

CODE THAT IS NOT WORKING (with fake link info):

<h4>Your submission was successful.</h4>

<p id="answ3">If you wish to enter additional addresses:</p>

<p id="answ2">It appears that the address you entered was not a mailing address (or was not marked as one). Please click the link below and enter a mailing address that can be used in the letter of authorization document. This is required by the utility, not us. Thank you.</p>
<button onclick="location.href='https://www.GOOGLE.COM/'" type="button">Add another address</button>

<p><span id="answ1">Or, if you are done entering addresses: </span></p>
<span id="answ4"><button onclick="location.href='https://www.GOOGLE.COM/'" type="button">Proceed to the Letter of Agreement</button></span><br />
<br />
<script>

A=document.getElementById("InsertRecordMailing_Addr_Type").value;
B=document.getElementById("InsertRecordMailing_Check").value;
md=A+B

if(md==0) { document.getElementById("answ1").style.display="none";
document.getElementById("answ3").style.display="none";
document.getElementById("answ4").style.display="none";
}
else { document.getElementById("answ2").style.display="none"; 
document.getElementById("InsertRecordMailing_Check").value=1;
}

</script>

 

What datatype those fields have? I have a few ideas, which I hope will be helpful.

- Your variables A, A and MD are not defined (the syntax var= is missing).

- "Insert record" syntax will not work since there is no form on the "show message" page, you can refer to fields using parameter picker, like var a = '[@Mailing_Addr_Type]';

- try using style.visibility.hidden instead of display none.

I have a simple example of the similar workflow.

<p id="first">[@field:First_name]</p>
<p id="second">[@field:Last_name]</p>
<script>
var x = '[@field:Last_name]';
var y= '[@field:First_name]';
if(x==y){
document.getElementById("first").style.visibility="hidden";
}else{
document.getElementById("second").style.visibility="hidden";
}
</script>

Hope that helps

Share this post


Link to post
Share on other sites

Thanks for your help.  The problem is now solved.  The keys were, as you said, the 'insertrecord' reference would not work in assigning the values to the variable or in the else portion of the if statement.  We had to program around that on the form itself.

I hope Caspio will update their pages regarding Java Script syntax for parameters to include those VERY VALUABLE tidbits of info.

 

Thank you Mathilda.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...