davepurchaser
Forum Replies Created
-
You’re awesome, thanks so much for your time. All works perfectly.
I think that this will work but there’s something wrong with the syntax of one of the HTML fields. When I load my form, the ‘next’ button doesn’t display. Also, the ‘div’ value appears as text in my field. That usually means there’s something off.
My hunch it is the <script> ticket.


Hi, I think I figured out a better way to do it by splitting up these two calculations and using an HTML Output field for each. I am not sure how to format them so they look like a complete sentence but at least the logic works now.
Thanks so much for your time and energy. You helped me a lot.
- This reply was modified 9 years, 4 months ago by davepurchaser.
I swear I’m not trolling you and I really do appreciate this, and please don’t kill me but… when I add fieldname4 to my list of fields to be evaluated, it returns
“You selected” fieldname4 “at” fielname4’%”
By self-evaluating it correctly calculates, but ends up calculating itself last.
Well that did solve the issue of it freezing my window. However, it does not force fieldname4 to dynamically update the onchange function, even if I turn dynamic calculations back on. I still have to trigger it manually.
My best guess is that it has something to do with the fact that fieldname4 (average calculation) is a calculated field whereas the onchange function is an HTML Content field.
Hey, thanks for bearing with me.
I get what you’re trying to do. You want to re-evaluate the onchange event on calculate, so that it picks up fieldname4. That is on the right track but unfortunately it just freezes my window.
Certainly. Thanks so much for having a look. It is here
http://143.95.252.125/~chadtesting/about/1.) select school (you can ignore e-mail)
2.) Pick a faculty
3.) Pick a course
4.) Put in a grade (you only need one)
5.) Calculatenotice output is 0%
Now if you hit “Previous” and re-do step 3, then step through it again, it works fine.
Am I wrong in thinking that the equation only evaluates fieldname 1-4 when there’s a change in the dropdowns, and the reason it’s not evaluating fieldname5 is because the equation begins by asking for something (evaluate a change in fieldname 1-4) that isn’t happening?
If I simply reversed the logic..
1.) Grab an average and output it to fieldname5
2.) Evaluate the last field chosen in dropdowns 1-4
3.) Output fieldname1-4 + fieldname 5 on calculate
This should work. In fact, it does work. I just don’t know how to change the code to run fieldname5 first.
I think it’s a triggering issue though. When I hit “Calculate” it triggers this equation
prec((function(){
var values = [fieldname2,fieldname6,fieldname73, fieldname74],
total = 0,
counter = 0;for(var i in values)
{
if(values[i]) counter++;
total += values[i];
}return (counter)?total/counter:0;
})(),1)… and outputs it to fieldname5. But in my HTML output which looks at
<script>
jQuery(document).on(
‘change’,
‘[id*=”fieldname1_”],[id*=”fieldname2_”],[id*=”fieldname3_”],[id*=”fieldname4_”],[id*=”fieldname5_”]’, function(){
jQuery(‘#result2’).html(‘You selected ‘+jQuery(this).val()+’ at ‘+jQuery(‘[id*=”fieldname5_”]’).val()+’%’);
return true;
});
</script>It seems to be waiting for me to go back to fieldnames 1-4 to pick it again. It won’t evaluate the output of the calculation in real time. It wants me to go back and pick a dropdown before it will evaluate it.
For example, if I calculate fieldname5 first, THEN pick between fields 1-4, it works fine.
- This reply was modified 9 years, 4 months ago by davepurchaser.
So here’s how my form works.
1.) I make a dropdown selection between fieldname1-4
2.) On the next page I calculate the average in fieldname5
3.) I output the selection in an HTML content field using the below logic (thanks very much for this. It mostly works wonderfully).
<script>
jQuery(document).on(
‘change’,
‘[id*=”fieldname1_”],[id*=”fieldname2_”],[id*=”fieldname3_”],[id*=”fieldname4_”],[id*=”fieldname5_”]’, function(){
jQuery(‘#result2’).html(‘You selected ‘+jQuery(this).val()+’ at ‘+jQuery(‘[id*=”fieldname5_”]’).val()+’%’);
});
</script>;If I skip the dropdown (1-4) step in my form and calculate fieldname5 first, then back up and select dropdowns between 1-4, everything works properly. If I select between 1-4 first, then try to calculate fieldname5, fieldname5 comes back with 0% in my HTML content field. It’s worth noting that the calculated field calculates fine.
Something about the way the code in the HTML content field evaluates the second step needs to be fixed because it seems like it’s dependent on fieldnames 1-4 and really I’m just calling it from a different calculated field.
Can you help?
- This reply was modified 9 years, 4 months ago by davepurchaser.
- This reply was modified 9 years, 4 months ago by davepurchaser.
- This reply was modified 9 years, 4 months ago by davepurchaser.
- This reply was modified 9 years, 4 months ago by davepurchaser.
- This reply was modified 9 years, 4 months ago by davepurchaser.
- This reply was modified 9 years, 4 months ago by davepurchaser.
- This reply was modified 9 years, 4 months ago by davepurchaser.
- This reply was modified 9 years, 4 months ago by davepurchaser.
scratch this – thinking
- This reply was modified 9 years, 4 months ago by davepurchaser.
- This reply was modified 9 years, 4 months ago by davepurchaser.
Hi codepeople, this almost works!
When I hit ‘calculate’ the first time, it still comes up as 0%. However, if I select a different option and calculate again, it outputs correctly.
For some reason, the first time I calculate it still sits at 0%.
- This reply was modified 9 years, 4 months ago by davepurchaser.
Ah so I’ve been trying to figure this out all night. fieldname5 in the above example is a number and it keeps returning a 0.
fieldname5 is a calculated field with the below equation. It’s worth noting that it outputs the correct value in the calculated field, but when I try to insert it into my HTML content field, it always returns a 0.
For example:
You selected red with 0%
prec((function(){
var values = [fieldname2,fieldname6,fieldname73, fieldname74],
total = 0,
counter = 0;for(var i in values)
{
if(values[i]) counter++;
total += values[i];
}return (counter)?total/counter:0;
})(),1)- This reply was modified 9 years, 5 months ago by davepurchaser.
- This reply was modified 9 years, 5 months ago by davepurchaser.
- This reply was modified 9 years, 5 months ago by davepurchaser.
Ahhh I’ve almost got it. This is driving me nuts.
I’m trying to write the following
<script>
jQuery(document).on(
‘change’,
‘[id*=”fieldname1_”],[id*=”fieldname2_”],[id*=”fieldname3_”],[id*=”fieldname4_”]’, function(){
jQuery(‘#result2’).html(‘You selected ‘+jQuery(this).val()+ ‘ at’ +(fieldname5)+ ‘ %’);
});
</script>The only thing I added to your script was +fieldname5+ and I can’t seem to find the right syntax to make it output. It should be able to grab another field in the output right?
Please help.
- This reply was modified 9 years, 5 months ago by davepurchaser.
- This reply was modified 9 years, 5 months ago by davepurchaser.