mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
Ecmascript: write to the variable selectedIndex. Not tested
This commit is contained in:
parent
d9d6bc23ae
commit
cdd86d3c20
@ -331,6 +331,16 @@ input_put(struct SEE_interpreter *interp, struct SEE_object *o,
|
||||
mem_free_set(&fs->value, string);
|
||||
if (fc->type == FC_TEXT || fc->type == FC_PASSWORD)
|
||||
fs->state = strlen(fs->value);
|
||||
} else if (p == s_selectedIndex) {
|
||||
if (fc->type == FC_SELECT) {
|
||||
SEE_uint32_t item = SEE_ToUint32(interp, val);
|
||||
|
||||
if (item >=0 && item < fc->nvalues) {
|
||||
fs->state = item;
|
||||
mem_free_set(&fs->value, stracpy(fc->values[item]));
|
||||
fixup_select_state(fc, fs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -300,6 +300,17 @@ input_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
||||
if (fc->type == FC_TEXT || fc->type == FC_PASSWORD)
|
||||
fs->state = strlen(fs->value);
|
||||
break;
|
||||
case JSP_INPUT_SELECTED_INDEX:
|
||||
if (fc->type == FC_SELECT) {
|
||||
int item = atoi(jsval_to_string(ctx, vp));
|
||||
|
||||
if (item >= 0 && item < fc->nvalues) {
|
||||
fs->state = item;
|
||||
mem_free_set(&fs->value, stracpy(fc->values[item]));
|
||||
fixup_select_state(fc, fs);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
INTERNAL("Invalid ID %d in input_set_property().", JSVAL_TO_INT(id));
|
||||
|
@ -89,7 +89,7 @@ done_submitted_value(struct submitted_value *sv)
|
||||
mem_free(sv);
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
fixup_select_state(struct form_control *fc, struct form_state *fs)
|
||||
{
|
||||
int i;
|
||||
|
@ -72,6 +72,7 @@ struct uri *get_form_uri(struct session *ses, struct document_view *doc_view, st
|
||||
|
||||
unsigned char *get_form_info(struct session *ses, struct document_view *doc_view);
|
||||
|
||||
void fixup_select_state(struct form_control *fc, struct form_state *fs);
|
||||
void selected_item(struct terminal *term, void *item_, void *ses_);
|
||||
int get_current_state(struct session *ses);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user