Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #24986 > unrolled thread
| Started by | pas cal <pbrcaso@gmail.com> |
|---|---|
| First post | 2014-06-24 01:21 -0700 |
| Last post | 2014-06-26 16:08 +0200 |
| Articles | 8 — 3 participants |
Back to article view | Back to comp.lang.javascript
update or keep drop down dependant lists with selected box value pas cal <pbrcaso@gmail.com> - 2014-06-24 01:21 -0700
Re: update or keep drop down dependant lists with selected box value "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-06-24 10:35 +0200
Re: update or keep drop down dependant lists with selected box value pas cal <pbrcaso@gmail.com> - 2014-06-24 01:43 -0700
Re: update or keep drop down dependant lists with selected box value "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-06-24 10:52 +0200
Re: update or keep drop down dependant lists with selected box value pas cal <pbrcaso@gmail.com> - 2014-06-24 02:57 -0700
Re: update or keep drop down dependant lists with selected box value "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-06-24 15:21 +0200
Re: update or keep drop down dependant lists with selected box value bpascal123 <bpascal123@gmail.com> - 2014-06-26 05:31 -0700
Re: update or keep drop down dependant lists with selected box value "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-06-26 16:08 +0200
| From | pas cal <pbrcaso@gmail.com> |
|---|---|
| Date | 2014-06-24 01:21 -0700 |
| Subject | update or keep drop down dependant lists with selected box value |
| Message-ID | <5b73b634-ba4b-442c-8ddf-10904b15ec69@googlegroups.com> |
Hi,
I am struggling with a javascript and I think jquery script drop down dependant validation list. After submitting using php, the value of the second drop down changes to the first initial value.
Is there a way to keep this value as it is after the user choice?
All the code for this:
html form (single form)
<?php
if (!isset($_POST['Submit'])){
?>
<form id="io30_form" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>" name="form_submitted">
<?php
}
?>
<form id="io30_form" method="POST" name="form_submitted">
html 1st select list
<select class="select_Y" name="FLexA" id="LexikA">
<option value="0" >Please choose a context...</option>
<option value="1" <?php if (@$_POST['FLexA']==1) {echo "selected='selected'"; } ?> >Human nature , Health, Ethic, Religion...</option>
<option value="2" <?php if (@$_POST['FLexA']==2) {echo "selected='selected'"; } ?> >Business, Law, Finance...</option>
</select>
html 2nd dependant select list
<select class="select_Y" name="FLexB" id="LexikB" jqsd:depends_on="LexikA" jqsd:hide_mode="disable">
<option value="0">Please choose a sub context...</option>
<!-- --------------DD 1 ------------------->
<option value="2" rel="1" <?php if (@$_POST['FLexB']==2) {echo "selected='selected'"; } ?> >Business, Law, Finance...</option>
<option value="3" rel="1" <?php if (@$_POST['FLexB']==3) {echo "selected='selected'"; } ?> >Sport, competition...</option>
<!-- --------------DD 2 ------------------->
<option value="1" rel="2" <?php if (@$_POST['FLexB']==1) {echo "selected='selected'";} ?> >Human nature , Health, Ethic, Religion...</option>
<option value="4" rel="2" <?php if (@$_POST['FLexB']==4) {echo "selected='selected'";} ?> >Wildlife, geography...</option>
</select>
<input type="Submit" name="Submit" value="Search" class="search">
</form>
javascript
new (function() {
var jqsdElements = { };
this.changeActiveState = function(obj, mode, enabled) {
switch (mode) {
case 'hide':
if (enabled) {
obj.show();
} else {
obj.hide();
}
break;
case 'disable':
default:
if (enabled) {
obj.attr('disabled', false);
} else {
obj.attr('disabled', 'disabled');
}
break;
}
};
this.disableChildren = function(node_id) {
if (node_id in jqsdElements) {
for (var dependent in jqsdElements[node_id]) {
var el = $('#' + dependent);
var mode = el.attr('jqsd:hide_mode');
el.find(':nth-child(1)').prop('selected',true);
this.changeActiveState(el, mode, false);
this.disableChildren(dependent);
}
}
};
this.onChange = function(id, val) {
for (var dependent in jqsdElements[id]) {
var dObj = $('#' + dependent);
var keys = ['_ALL_'];
if (val in jqsdElements[id][dependent]['options']) {
keys[keys.length] = val;
}
dObj.find('option').remove();
var totalOps = 0;
var opsToAdd = { };
for (var i=0;i<keys.length;i++) {
var key = keys[i];
for (var optOrder in jqsdElements[id][dependent]['options'][key]) {
var opt = jqsdElements[id][dependent]['options'][key][optOrder];
opsToAdd[optOrder] = opt;
totalOps++;
}
}
if (Object.keys) {
var reOrder = opsToAdd, keys = Object.keys(opsToAdd), i, len = keys.length;
keys.sort();
for (i = 0; i < len; i++) {
k = keys[i];
dObj.append(opsToAdd[k]);
}
} else {
for (var orderKey in opsToAdd) {
dObj.append(opsToAdd[orderKey]);
}
}
dObj.find(':nth-child(1)').prop('selected',true);
this.disableChildren(dependent);
if (totalOps > 0) {
if (totalOps == 1) {
if (dObj.find(':nth-child(1)').val() != '') {
this.changeActiveState(dObj, jqsdElements[id][dependent].hidemode, true);
}
} else {
this.changeActiveState(dObj, jqsdElements[id][dependent].hidemode, true);
}
}
}
};
this.init = function() {
var p = this;
$('select[jqsd\\:depends_on]').each(function() {
var selId = $(this).attr('id');
if (!selId) {
alert('JQSD Error - One or more selects are missing id values');
return;
}
var hideMode = ($(this).attr('jqsd:hide_mode')) ? $(this).attr('jqsd:hide_mode') : 'disable';
var depends_on = $(this).attr('jqsd:depends_on');
p.changeActiveState($(this), hideMode, false);
if ($('#' + depends_on).length == 0) {
alert('JQSD Error - One or more selects are missing id values');
return;
}
var options = {
'_ALL_': { }
};
var optOrder = 0;
$(this).find('option').each(function() {
var rel = $(this).attr('rel');
if (!rel) {
options['_ALL_'][optOrder] = $(this);
} else {
var opts = rel.split(',');
for (var i=0;i<opts.length;i++) {
if (!options[opts[i]]) {
options[opts[i]] = [ ];
}
options[opts[i]][optOrder] = $(this);
}
}
optOrder++;
});
if (!jqsdElements[depends_on]) {
jqsdElements[depends_on] = { };
}
jqsdElements[depends_on][selId] = {
options: options,
hidemode: hideMode
};
p.onChange(depends_on, $('#' + depends_on).val());
});
$('select').on('change', $.proxy(function(evt) {
var id = $(evt.target).attr('id');
if (!(id in jqsdElements)) {
return;
}
var val = $(evt.target).val();
this.onChange(id, val);
}, this));
}
this.preInit = function() {
$(document).ready($.proxy(this.init, this));
}
})().preInit();
any ideas?
Pascal
[toc] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2014-06-24 10:35 +0200 |
| Message-ID | <XnsA3566BB7E6F32eejj99@194.109.133.133> |
| In reply to | #24986 |
pas cal <pbrcaso@gmail.com> wrote on 24 jun 2014 in comp.lang.javascript:
> I am struggling with a javascript
I would think so.
> and I think jquery script drop down dependant validation list.
Is this a sentence? We don't speak jquery here.
> After submitting using php,
Nor php.
> javascript
>
> new (function() {
Why the "new" and the "("?
Get your act together by first making a simple page,
without php and without jquery, and test that
using the debugging facilities of chrome or firefox.
Only when debugged slowly introduce PHP.
Never again use jquery,
[untill you understand the non-understandable]
at least in this NG.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | pas cal <pbrcaso@gmail.com> |
|---|---|
| Date | 2014-06-24 01:43 -0700 |
| Message-ID | <753ce827-7b02-4f12-acbf-6ab9200439a6@googlegroups.com> |
| In reply to | #24988 |
the whole thing about this is that I purchase a solution from a freelance site and the cost was quite consequent.
Now I am not a javascript or even web client or server coder. I've got some C backgrounds but my main understanding is visual basic ... not even much of .net.
I would understand that a drop down validation list would keep a value by default. I can retrieve it using php $_POST but why if I use //document.getElementById("LexikB").value="aaa"; I can't update the content of the drop down current selection
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2014-06-24 10:52 +0200 |
| Message-ID | <XnsA3566E95C5629eejj99@194.109.133.133> |
| In reply to | #24989 |
pas cal <pbrcaso@gmail.com> wrote on 24 jun 2014 in comp.lang.javascript: > the whole thing about this is that I purchase a solution from a > freelance site and the cost was quite consequent. And you want us to improve on it for free? Please be equally consequent and hire a professional programmer! btw, how do you know it is "a solution", if it does not do what you want to solve your problem? > Now I am not a javascript or even web client or server coder. You can learn. We all did. -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | pas cal <pbrcaso@gmail.com> |
|---|---|
| Date | 2014-06-24 02:57 -0700 |
| Message-ID | <19bf9bc6-0c49-473d-b776-aded08cb9d05@googlegroups.com> |
| In reply to | #24991 |
I have solved many people problems for free excel...vba as bpascal123. I see this as a small feature less than 100 lines of code. Anyway, I am not in hurry for this. With time, answers come
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2014-06-24 15:21 +0200 |
| Message-ID | <XnsA3569C40FC4eejj99@194.109.133.133> |
| In reply to | #24993 |
pas cal <pbrcaso@gmail.com> wrote on 24 jun 2014 in comp.lang.javascript: > I have solved many people problems for free excel...vba as bpascal123. I > see this as a small feature less than 100 lines of code. Anyway, I am > not in hurry for this. With time, answers come Is there a "free excel"? What feature? What are you responding on? Please quote, this is usenet. We don't get responses in order, depending on the newsserver used. -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | bpascal123 <bpascal123@gmail.com> |
|---|---|
| Date | 2014-06-26 05:31 -0700 |
| Message-ID | <84924f79-710f-47e7-ae30-f6532b785989@googlegroups.com> |
| In reply to | #25003 |
is there a free computer?
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2014-06-26 16:08 +0200 |
| Message-ID | <XnsA358A41EB3B72eejj99@194.109.133.133> |
| In reply to | #25041 |
bpascal123 <bpascal123@gmail.com> wrote on 26 jun 2014 in comp.lang.javascript: > is there a free computer? Sure, on Singapore airport usually. Are you responding on something? This is usenet, if you respond, you should quote. -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web