获取所选ColdFusion单选按钮的ID(非值)(Get ID (not value) of selected ColdFusion radio button)
我在ColdFusion中创建了一个测验,一个表中有问题,另一个表中有答案; 它是多种选择,每个答案都是作为一个广播组的成员呈现的。 我正在遍历我的记录集rsAnswers,以输出无线电组。 我需要为Insert操作获取所选单选按钮的数据库ID,但无法弄明白。
这是我输出问题和答案的方式:
<h3>Question #<cfoutput>#Session.theQuestion#</cfoutput></h3> <h3><cfoutput>#rsQuestion.rrqQuestion#</cfoutput></h3> <ol type="A" id="answerList"> <cfoutput query="rsAnswers"> <li> <label> <input type="radio" name="theAnswers" id=#rsAnswers.ID#" value="#rsAnswers.rraValue#" /> #rsAnswers.rraAnswer#</label> </li> </cfoutput> </ol>
如果我可以检索所选单选按钮的ID属性,我会没事的,但我没有看到在CF中这样做的方法。 我错过了什么?
TIA - 乔
I've created a quiz in ColdFusion with questions in one table and answers in another; it's multiple choice and each answer is presented as a member of a radio group. I'm looping through my recordset, rsAnswers, to output the radio group. I need to get the database ID of the selected radio button for an Insert operation and can't figure it out.
Here's how I'm outputting the question and answers:
<h3>Question #<cfoutput>#Session.theQuestion#</cfoutput></h3> <h3><cfoutput>#rsQuestion.rrqQuestion#</cfoutput></h3> <ol type="A" id="answerList"> <cfoutput query="rsAnswers"> <li> <label> <input type="radio" name="theAnswers" id=#rsAnswers.ID#" value="#rsAnswers.rraValue#" /> #rsAnswers.rraAnswer#</label> </li> </cfoutput> </ol>
If I could retrieve the ID attribute of the selected radio button, I'd be fine, but I don't see a way to do that in CF. What am I missing?
TIA - Joe
原文:https://stackoverflow.com/questions/32280897
最满意答案
对于
nls
您必须更仔细地指定参数。 此外,您可能不想使用log(y)
,因为这将绘制对数而不是y
。 我的猜测是你想使用y ~ exp(a + b * x)
。 请参阅下面的示例。ggplot(df, aes(x = t, y = m))+ geom_point()+ geom_smooth(method = "nls", formula = y ~ exp(a + b * x), start=list(a=0, b=1), se=FALSE)
你也可以使用
glm
而不是nls
。 例如,以下内容为您提供相同的解决方案。ggplot(df, aes(x = t, y = m))+ geom_point()+ geom_smooth(method = "glm", formula = y ~ x, family=gaussian(link = "log"), se=FALSE)
For
nls
you have to specify the parameters more carefully. Also, you probably don't want to uselog(y)
, because that will plot the logarithm instead ofy
. My guess is that you want to use something likey ~ exp(a + b * x)
. See below for an example.ggplot(df, aes(x = t, y = m))+ geom_point()+ geom_smooth(method = "nls", formula = y ~ exp(a + b * x), start=list(a=0, b=1), se=FALSE)
You could also use
glm
instead ofnls
. For instance the following gives you the same solution.ggplot(df, aes(x = t, y = m))+ geom_point()+ geom_smooth(method = "glm", formula = y ~ x, family=gaussian(link = "log"), se=FALSE)
相关问答
更多-
对于nls您必须更仔细地指定参数。 此外,您可能不想使用log(y) ,因为这将绘制对数而不是y 。 我的猜测是你想使用y ~ exp(a + b * x) 。 请参阅下面的示例。 ggplot(df, aes(x = t, y = m))+ geom_point()+ geom_smooth(method = "nls", formula = y ~ exp(a + b * x), start=list(a=0, b=1), se=FALSE) 你也可以使用glm而不是nls 。 例如,以下内 ...
-
有几个问题: formula是nls一个参数,你需要传递一个公式对象给它,而不是一个字符。 ggplot2将y和x传递给nls而不是fold和t 。 默认情况下, stat_smooth尝试获取置信区间。 这在predict.nls没有实现。 综上所述: d <- ggplot(test,aes(x=t, y=fold))+ #to make it obvious I use argument names instead of positional matching geom_poi ...
-
出现错误是因为没有任何名为“date”和“ratio”的变量。 这很好用: library(ggplot2) df <- as.data.frame(read.table("unemp.txt", header = TRUE, colClasses = c("Date", "numeric"))) names(df) <- c("date", "ratio") p <- ggplot(df,aes(x=date,y=ratio)) p + geom_point() + geom_smooth() + xl ...
-
我的问题是:使用这种结构,是否可以从该调用中拉出实际的nls对象? 我想知道我的系数等。 这在ggplot2中目前是不可能的。 ggplot2函数从模型返回预测,但不返回模型对象本身。 因此,您无法从ggplot对象中提取nls对象以查找系数等。 ggplot2和ggplot2-dev邮件列表中有两个相关的讨论: https://groups.google.com/d/topic/ggplot2/7tiUB2sjCxM/discussion https://groups.google.com/d/topic ...
-
带有嵌套函数的nls2(nls2 with nested functions)[2024-01-05]
f1和这里都没有任何参数,因此在理解如何优化f1一些困难并不令人惊讶。 nls2::nls2 (如stats::nls )需要一个formula作为第一个参数。 该公式可以从任何你想要的功能构建而成,并且不必在通话中完全写下来。 您可以执行以下操作: a <- function(d){ d+1 } f1 <- function(b,d,x){ y <- a(d)*x/(b+x) } 然后适合这样的模型: nls2(y~f1(b,d,x), start = st, algorithm = "bru ... -
您在帖子中链接的答案是在3年前发布的, ggplot2 , ggplot2许多内容自此以后发生了变化。 那时, ggplot2版本0.9.0尚未发布。 根据absoluteGrob的1.0.0文档 ,它仍然是实验性的,这意味着它在链接答案时肯定是实验性的。 此时,它很可能从ggplot2名称空间导出,因此可供用户使用。 这就是为什么链接的答案在当时起作用的原因。 但是,从版本1.0.1开始,它不会从ggplot2名称空间导出。 因此,虽然您可以使用ggplot2:::absoluteGrob (适用于非导出 ...
-
'闭包'类型的ggplot2条形图对象不是子集[重复](ggplot2 bar graph object of type 'closure' is not subsettable [duplicate])[2024-01-13]
问题很简单,但追踪它确实是一项艰巨的任务。 stat=identity应该是stat="identity" 。 我也改变了fill=treatment以获得以下图片: ggplot(summary.2, aes(x=genotype, y=height, fill=treatment)) + geom_bar(position=position_dodge(), stat="identity", colour="black") + geom_errorbar(aes(ymin=height ... -
我相信,当您使用响应的自然对数变换拟合模型时,您只需要允许单独的斜率和截距适合您的分组变量Factor 。 我称之为单独的线条模型。 然后,您可以预测并获得每个Factor对数标度上的置信度(或预测)间隔,并进行反向变换以查看线条(非常类似于ggplot2原始帖子中的ggplot2 。 R中单独的线模型示例: fit1 = lm(y ~ time*Factor, data = x) summary(fit1) 该模型的输出将显示Factor的参考水平的估计截距,参考水平的估计斜率,以及参考水平和所有其他水 ...
-
理想的解决方案是使用ggplot绘制nls()的结果,但这是基于一些观察的“快速而肮脏”的解决方案。 首先,您可以确定如果对nls()和geom_smooth(method = "nls")使用相同的公式,您将获得相同的系数。 那是因为后者正在呼唤前者。 其次,使用您的示例数据,无论起始值如何, nls()收敛到相同的Vmax和Km值(每种药物都不同)。 换句话说,没有必要使用每种药物的范围内的起始值来构建模型。 以下任何一项对药物1给出相同的结果(对于药物2也是如此): library(dplyr) # ...
-
'闭合'类型的对象不是子集[GGplot2,Shiny](object of type 'closure' is not subsettable [GGplot2, Shiny])[2022-03-28]
你想从aes调用中删除df$ : p <- ggplot(df,aes(timestamp,power))+theme_bw() +geom_point() 这是因为aes 的作用范围 You want to remove the df$ from inside the aes call: p <- ggplot(df,aes(timestamp,power))+theme_bw() +geom_point() This is because of how aes is scoped