我打算为主要车型(瑞典汽车)提供简要描述页面。我还想表明沃尔沃和萨博在下拉列车中属于瑞典汽车。然后当我点击沃尔沃时,它应该导航到沃尔沃描述页面。如何将optgroup标签显示为最初选择的?
谢谢。
#include <stdio.h>
#include <string>
#include <ctype.h>
int main()
{
int strLength;
int *ptr_strLength;
char textStream[];
int cont = 1;
while (cont != 0)
{
scanf("%s", textStream[]);
strLength = strlen(textStream[]);
}
ptr_strLength = &strLength;
void findLetters(ptr_strLength);
)
void findLetters(int *ptr) //find occurences of all letters
{
int upLetters[26];
int loLetters[26];
char text[];
int index;
int a = 65;
int lowA = 97;
int b = 0;
int c = 0;
int d = 0;
int e = 0;
int i = 0;
int length;
length = *ptr;
while (textStream[i] != '\0')
{
for (; i < length ); i++)
{
if (isalpha(textStream[i])) //checks if char is an alphabet
{
for (; a < 123); a++)
{
if (textStream[i] = a)
{
if (textStream[i] > 64 && textStream[i] < 91) //stores occurrences of uppercase letters
{
textStream[i] - a = index;
upLetters[index] = upLetters[index] + textStream[i] - textStream[i] + 1;
}
if (textStream[i] > 89 && textStream[i] < 123) //stores occurrences of lowercase letters
{
textStream[i] - lowA = index;
loLetters[index] = loLetters[index] + textStream[i] - textStream[i] + 1;
}
}
}
}
printf("Number of Occurrences of letters\n\n");
if(upLetters[0] > 0)
{
printf("A : \t%d\n", upLetters[0]);
}
if(upLetters[1] > 0)
{
printf("B : \t%d\n", upLetters[1]);
}
if(upLetters[2] > 0)
{
printf("C : \t%d\n", upLetters[2]);
}
if(upLetters[3] > 0)
{
printf("D : \t%d\n", upLetters[3]);
}
if(upLetters[4] > 0)
{
printf("E : \t%d\n", upLetters[4]);
}
if(upLetters[5] > 0)
{
printf("F : \t%d\n", upLetters[5]);
}
if(upLetters[6] > 0)
{
printf("G : \t%d\n", upLetters[6]);
}
if(upLetters[7] > 0)
{
printf("H : \t%d\n", upLetters[7]);
}
if(upLetters[8] > 0)
{
printf("I : \t%d\n", upLetters[8]);
}
if(upLetters[9] > 0)
{
printf("J : \t%d\n", upLetters[9]);
}
if(upLetters[10] > 0)
{
printf("K : \t%d\n", upLetters[10]);
}
if(upLetters[11] > 0)
{
printf("L : \t%d\n", upLetters[11]);
}
if(upLetters[12] > 0)
{
printf("M : \t%d\n", upLetters[12]);
}
if(upLetters[13] > 0)
{
printf("N : \t%d\n", upLetters[13]);
}
if(upLetters[14] > 0)
{
printf("O : \t%d\n", upLetters[14]);
}
if(upLetters[15] > 0)
{
printf("P : \t%d\n", upLetters[15]);
}
if(upLetters[16] > 0)
{
printf("Q : \t%d\n", upLetters[16]);
}
if(upLetters[17] > 0)
{
printf("R : \t%d\n", upLetters[17]);
}
if(upLetters[18] > 0)
{
printf("S : \t%d\n", upLetters[18]);
}
if(upLetters[19] > 0)
{
printf("T : \t%d\n", upLetters[19]);
}
if(upLetters[20] > 0)
{
printf("U : \t%d\n", upLetters[20]);
}
if(upLetters[21] > 0)
{
printf("V : \t%d\n", upLetters[21]);
}
if(upLetters[22] > 0)
{
printf("W : \t%d\n", upLetters[22]);
}
if(upLetters[23] > 0)
{
printf("X : \t%d\n", upLetters[23]);
}
if(upLetters[24] > 0)
{
printf("Y : \t%d\n", upLetters[24]);
}
if(upLetters[25] > 0)
{
printf("Z : \t%d\n", upLetters[25]);
}
if(loLetters[0] > 0)
{
printf("a : \t%d\n", upLetters[0]);
}
if(loLetters[1] > 0)
{
printf("b : \t%d\n", upLetters[1]);
}
if(loLetters[2] > 0)
{
printf("c : \t%d\n", upLetters[2]);
}
if(loLetters[3] > 0)
{
printf("d : \t%d\n", upLetters[3]);
}
if(loLetters[4] > 0)
{
printf("e : \t%d\n", upLetters[4]);
}
if(loLetters[5] > 0)
{
printf("f : \t%d\n", upLetters[5]);
}
if(loLetters[6] > 0)
{
printf("g : \t%d\n", upLetters[6]);
}
if(loLetters[7] > 0)
{
printf("h : \t%d\n", upLetters[7]);
}
if(loLetters[8] > 0)
{
printf("i : \t%d\n", upLetters[8]);
}
if(loLetters[9] > 0)
{
printf("j : \t%d\n", upLetters[9]);
}
if(loLetters[10] > 0)
{
printf("k : \t%d\n", upLetters[10]);
}
if(loLetters[11] > 0)
{
printf("l : \t%d\n", upLetters[11]);
}
if(loLetters[12] > 0)
{
printf("m : \t%d\n", upLetters[12]);
}
if(loLetters[13] > 0)
{
printf("n : \t%d\n", upLetters[13]);
}
if(loLetters[14] > 0)
{
printf("o: \t%d\n", upLetters[14]);
}
if(loLetters[15] > 0)
{
printf("p : \t%d\n", upLetters[15]);
}
if(loLetters[16] > 0)
{
printf("q : \t%d\n", upLetters[16]);
}
if(loLetters[17] > 0)
{
printf("r : \t%d\n", upLetters[17]);
}
if(loLetters[18] > 0)
{
printf("s : \t%d\n", upLetters[18]);
}
if(loLetters[19] > 0)
{
printf("t : \t%d\n", upLetters[19]);
}
if(loLetters[20] > 0)
{
printf("u : \t%d\n", upLetters[20]);
}
if(loLetters[21] > 0)
{
printf("v : \t%d\n", upLetters[21]);
}
if(loLetters[22] > 0)
{
printf("w : \t%d\n", upLetters[22]);
}
if(loLetters[23] > 0)
{
printf("x : \t%d\n", upLetters[23]);
}
if(loLetters[24] > 0)
{
printf("y : \t%d\n", upLetters[24]);
}
if(loLetters[25] > 0)
{
printf("z : \t%d\n", upLetters[25]);
}
}
}
答案 0 :(得分:0)
我相信你要求的东西会像这样呈现:
这不是严格,因为您无法“选择”选项组标签。为了获得你正在寻找的效果,你将不得不执行一些技巧。
我们可以将自定义标签放入span
,并将此范围绝对放在select
上,以使初始选择显示为作为选项组标签。之后我们需要一些javascript来伪造click
和change
事件,您可以在下面看到一个工作示例。但是,这就是你的html的样子:
<div class="select-wrapper">
<span>Swedish Cars</span>
<select>
<optgroup class="swe-car" label="Swedish Cars">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
</optgroup>
</select>
</div>
答案 1 :(得分:0)
答案 2 :(得分:0)
这个怎么样?我从另一个问题Selectable <optgroup> in HTML <select> tag复制答案
.optionGroup {
font-weight: bold;
font-style: italic;
}
.optionChild {
padding-left: 15px;
}
<select>
<option value="Swedish Cars" class="optionGroup">Swedish Cars</option>
<option value="volvo" class="optionChild">volvo</option>
<option value="saab" class="optionChild">saab</option>
</select>