6d3b0d4d71f3bfe41d5567dba0cd394229ab1005
angie
Fri Jul 1 11:51:36 2011 -0700
While debugging MLQ #4463, I noticed that jsMakeTrackingCheckBox wasimplemented in a way that would work if the checkbox was clicked a single
time (or odd number of times), but not if the checkbox was clicked an even
number of times. So if the user clicked the checkbox but changed their mind
and clicked again, and then changed the group or track, the checkbox would
change. Solution: make the variable toggle like the checkbox. Using +1 mod 2
so that our cart will see the expected 0 or 1 (not the logically inverted
true or false from ! negation).
diff --git src/hg/lib/jsHelper.c src/hg/lib/jsHelper.c
index 5dc100a..b640080 100644
--- src/hg/lib/jsHelper.c
+++ src/hg/lib/jsHelper.c
@@ -199,33 +199,33 @@
hPrintf(" CHECKED");
hPrintf(">");
}
void jsMakeTrackingCheckBox(struct cart *cart,
char *cgiVar, char *jsVar, boolean usualVal)
/* Make a check box filling in with existing value and
* putting a javascript tracking variable on it. */
{
char buf[256];
boolean oldVal = cartUsualBoolean(cart, cgiVar, usualVal);
hPrintf("\n", jsVar, oldVal);
hPrintf("");
-sprintf(buf, "%s%s", cgiBooleanShadowPrefix(), cgiVar);
+safef(buf, sizeof(buf), "%s%s", cgiBooleanShadowPrefix(), cgiVar);
cgiMakeHiddenVar(buf, "0");
}
void jsTrackedVarCarryOver(struct dyString *dy, char *cgiVar, char *jsVar)
/* Carry over tracked variable (radio button?) to hidden form. */
{
dyStringPrintf(dy, "document.hiddenForm.%s.value=%s; ", cgiVar, jsVar);
}
char *jsRadioUpdate(char *cgiVar, char *jsVar, char *val)
/* Make a little javascript to check and uncheck radio buttons
* according to new value. To use this you must have called
* jsWriteFunctions somewhere, and also must use jsMakeTrackingRadioButton
* to make the buttons. */
{