【问题标题】:Checkboxes within Select list选择列表中的复选框
【发布时间】:2013-08-19 19:03:52
【问题描述】:

如何在选择列表中添加复选框?该列表是由一些 xquery 代码生成的,因此有点复杂。我正在努力弄清楚如何在这里使用“输入”标签。

{if( $workcount > 1 )
then
<form name="bentform" action="{$g:blakeroot}archive/comparison.xq" onSubmit="return mySubmit()" target="comparison">
<input name="selection" type="submit" value="Compare" onClick="document.bentform.target='BentWin'"/>
<br/><br/>  
<select name="copies" multiple="multiple" size="3" >
<option selected="yes" value="all">All Copies and *Versions from Other Works*</option>
{for $copies in collection($g:collection)/bad[starts-with(@id , $workid)]/@id
let $bad := collection($g:collection)/bad[@id = $copies]
let $copyversion := string($bad/@copy), 
  $comporder := $bad[@id = $copies]//compdate[1]/@value, 
  $printorder :=$bad[@id = $copies]//printdate[1]/@value, 
  $printdate := $bad[@id = $copies]//printdate[1]/@value,
  $repository := $bad//repository/institution/text(),
  $repcount := count($repository)
 order by ($bad//compdate)[1]/@value, ($bad//printdate)[1]/@value, g:copydesignation($copies)
return 
if ($copies != $copyid)
then
<option value="{$copies}"><striptags>{if(exists($copyversion))then <wrap>{$copyversion}, </wrap>else ""} {string(substring-before( $printdate, '.' ))} ({if($repcount = 1) then $repository else <wrap>Multiple ({$repcount}) Institutions</wrap> })</striptags></option>
else if ( $compwith != "" ) then 
<p>If this worked, I'd be comparing this plate with {$compwith}</p>
else "..."
}

【问题讨论】:

    标签: html list select checkbox xquery


    【解决方案1】:
        {if( $workcount > 1 )
        then
        <form name="bentform" action="{$g:blakeroot}archive/comparison.xq" onSubmit="return mySubmit()" target="comparison">
        <input name="selection" type="submit" value="Compare" onClick="document.bentform.target='BentWin'"/>
        <br/><br/>  
        <input type="checkbox" name="copies[]" value="all" id="all" /><label for="all">All Copies and *Versions from Other Works*</label>
        {for $copies in collection($g:collection)/bad[starts-with(@id , $workid)]/@id
        let $bad := collection($g:collection)/bad[@id = $copies]
        let $copyversion := string($bad/@copy), 
          $comporder := $bad[@id = $copies]//compdate[1]/@value, 
          $printorder :=$bad[@id = $copies]//printdate[1]/@value, 
          $printdate := $bad[@id = $copies]//printdate[1]/@value,
          $repository := $bad//repository/institution/text(),
          $repcount := count($repository)
         order by ($bad//compdate)[1]/@value, ($bad//printdate)[1]/@value, g:copydesignation($copies)
        return 
        if ($copies != $copyid)
        then
        <input type="checkbox" name="copies[]" value="{$copies}" id="{$copies}" /><label for="{$copies}"><striptags>{if(exists($copyversion))then <wrap>{$copyversion}, </wrap>else ""} {string(substring-before( $printdate, '.' ))} ({if($repcount = 1) then $repository else <wrap>Multiple ({$repcount}) Institutions</wrap> })</striptags></label>
        else if ( $compwith != "" ) then 
        <p>If this worked, I'd be comparing this plate with {$compwith}</p>
        else "..."
        }
    

    【讨论】:

    • 谢谢。但我在这一行遇到错误: 解析错误:包含空格的元素名称:期待“else”,在第 227 行第 82 行找到“for”
    • 在我摆脱了那个解析错误之后,我尝试了你的代码。结果是这些项目不再在表单框中。它应该如下所示:careers.microsoft.com/search.aspx
    猜你喜欢
    • 2010-12-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多