bool SelectElement::appendFormData(SelectElementData& data, Element* element, FormDataList& list) { const AtomicString& name = element->formControlName(); if (name.isEmpty()) return false; bool successful = false; const Vector<Element*>& items = data.listItems(element); for (unsigned i = 0; i < items.size(); ++i) { OptionElement* optionElement = toOptionElement(items[i]); if (optionElement && optionElement->selected()) { list.appendData(name, optionElement->value()); successful = true; } } // FIXME: This case should not happen. Make sure that we select the first option // in any case, otherwise we have no consistency with the DOM interface. // We return the first one if it was a combobox select if (!successful && !data.multiple() && data.size() <= 1 && items.size()) { OptionElement* optionElement = toOptionElement(items[0]); const AtomicString& value = optionElement->value(); if (value.isNull()) list.appendData(name, optionElement->text().stripWhiteSpace()); else list.appendData(name, value); successful = true; } return successful; }
void WMLSelectElement::updateVariables() { WMLPageState* pageState = wmlPageStateForDocument(document()); if (!pageState) return; String name = this->name(); String iname = this->iname(); if (iname.isEmpty() && name.isEmpty()) return; String nameString; String inameString; unsigned optionIndex = 0; const Vector<Element*>& items = m_data.listItems(this); for (unsigned i = 0; i < items.size(); ++i) { OptionElement* optionElement = toOptionElement(items[i]); if (!optionElement) continue; ++optionIndex; if (!optionElement->selected()) continue; if (!nameString.isEmpty()) nameString += ";"; if (!inameString.isEmpty()) inameString += ";"; nameString += optionElement->value(); inameString += String::number(optionIndex); } if (!name.isEmpty()) pageState->storeVariable(name, nameString); if (!iname.isEmpty()) pageState->storeVariable(iname, inameString); }