sydneyguy
asked on
php java cascade and multiselect box need to be able to extract the multi select ans still cascade
i have a section of code that i am assembaling from a cascade menu as below. can get the alert pop up to work, and can get the values of the select box with the below code. but when the system builds its self it creates the code by addign the line of code but cannot get the syntax correct to work ...any help woudl be appreciated
******** this is the code runs and when select is clicked an alert box comes up ********
code 1 working
if ($config['accept_county'] == 'Y' || $config['accept_county'] == '1') {
/* MODIFIED FOR MULTI SELECT */
$ret .= ' <select size="10" multiple="multiple" style="width: 175px "
onchange=" alert()"; >';
***** the below code needs to be substituted were onchange=" alert()"; lives to allow me to on
code 2 need to be substituted
click cycle through the items selected and save it to a text box *************
onChange='var v="",o=this.options;
for(var i=0;i<o.length;i++)
if(o[ i ].selected)v+=","+o[ i ] .value;
this.form.GenDisClassComb. value=v.su bstr(1)';
******** this is the code runs and when select is clicked an alert box comes up ********
code 1 working
if ($config['accept_county'] == 'Y' || $config['accept_county'] == '1') {
/* MODIFIED FOR MULTI SELECT */
$ret .= ' <select size="10" multiple="multiple" style="width: 175px "
onchange=" alert()"; >';
***** the below code needs to be substituted were onchange=" alert()"; lives to allow me to on
code 2 need to be substituted
click cycle through the items selected and save it to a text box *************
onChange='var v="",o=this.options;
for(var i=0;i<o.length;i++)
if(o[ i ].selected)v+=","+o[ i ] .value;
this.form.GenDisClassComb.
ASKER
sorry that works if you run it a blank alert box comes up that actually works of
what i need to do change
onchange=" alert()"; >';
to the code below, but get the syntax correct which i just cannot seem to get
onChange='var v="",o=this.options;
for(var i=0;i<o.length;i++)
if(o[ i ].selected)v+=","+o[ i ] .value;
this.form.GenDisClassComb. value=v.su bstr(1)';
its used in the context as below building the $ret .= '
function DiseasesModeledBuild($coun trycode) {
global $config;
if ( ($config['accept_country'] == '1' || $config['accept_country'] == 'Y' ) && $countrycode == 'AA' ) {
return '<input name="srchlookstate_provin cedis" type="text" class="textinput" size="30" maxlength="100" />';
}
$ret = '';
$data = DiseasesModeled(trim($coun trycode),' N');
if (count($data) < 1) return '<input name="srchlookstate_provin cedis" type="text" class="textinput" size="30" maxlength="100" />';
if ($config['accept_county'] == 'Y' || $config['accept_county'] == '1') {
/* MODIFIED FOR MULTI SELECT ********** PROBLEM BELOW */
$ret .= ' <select size="10" multiple="multiple" style="width: 175px"
onchange=" alert()"; >'; /* THIS NEEDS TO CHANGE */
/* onchange="javascript: cascadeState(this.value,th is.form.sr chlookcoun try.value) ;" */
}
/* $ret .= '<option value="AA">'.get_lang('sel ect_organt issue').'< /option>'; */
foreach ($data as $k => $y){
if ($k != 'AA') {
$ret .= "<option value='$k'>$y</option>";
}
}
unset ($data);
return $ret .= '</select>';
}
what i need to do change
onchange=" alert()"; >';
to the code below, but get the syntax correct which i just cannot seem to get
onChange='var v="",o=this.options;
for(var i=0;i<o.length;i++)
if(o[ i ].selected)v+=","+o[ i ] .value;
this.form.GenDisClassComb.
its used in the context as below building the $ret .= '
function DiseasesModeledBuild($coun
global $config;
if ( ($config['accept_country']
return '<input name="srchlookstate_provin
}
$ret = '';
$data = DiseasesModeled(trim($coun
if (count($data) < 1) return '<input name="srchlookstate_provin
if ($config['accept_county'] == 'Y' || $config['accept_county'] == '1') {
/* MODIFIED FOR MULTI SELECT ********** PROBLEM BELOW */
$ret .= ' <select size="10" multiple="multiple" style="width: 175px"
onchange=" alert()"; >'; /* THIS NEEDS TO CHANGE */
/* onchange="javascript: cascadeState(this.value,th
}
/* $ret .= '<option value="AA">'.get_lang('sel
foreach ($data as $k => $y){
if ($k != 'AA') {
$ret .= "<option value='$k'>$y</option>";
}
}
unset ($data);
return $ret .= '</select>';
}
ASKER
$ret .= ' <select size="10" multiple="multiple" style="width: 175px"
onChange="var v="",o=this.options;
for(var i=0;i<o.length;i++)
if(o[i].selected)v+=","+o[ i].value;
this.form.GenDisClassComb. value=v.su bstr(1)"; >';
THIS IS THE CORRECT SYNTAX WHICH WILL COMPILE AND RUN BUT WILL NOT RUN THE ONCHANGE FUNCTION
onChange="var v="",o=this.options;
for(var i=0;i<o.length;i++)
if(o[i].selected)v+=","+o[
this.form.GenDisClassComb.
THIS IS THE CORRECT SYNTAX WHICH WILL COMPILE AND RUN BUT WILL NOT RUN THE ONCHANGE FUNCTION
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
this code is created dynamicaly as the cascade parent is selected the cascade code jumps to and finds all the options required from the parent , then this code should be set up on the select box to allow the onchange code to run.
i can get the alert () code to run but will not run the item select code???
must be a syntex or txt box not found in form or some thing silly
i can get the alert () code to run but will not run the item select code???
must be a syntex or txt box not found in form or some thing silly
Look in the browser resulting html text and you will see whether you get single " instead of "" and so on.
it is trying to update a form element with name "GenDisClassComb" Most of the time this is something like a hidden field. You could try using document.getElementById() and make sure the field you are trying to update has a unique id so the code would change to this:
$ret .= '<select size="10" multiple="multiple" style="width: 175px"
onChange="var v=\'\';o=this.options; for(var i=0;i<o.length;i++) if(o[i].selected)v+=\',\'+ o[i].value ;document. getElement ById(\'Gen DisClassCo mb\').valu e=v.substr (1);">';
and the hidden field might be something like this:
<input type="hidden" name="GenDisClassComb" id="GenDisClassComb" value="" />
$ret .= '<select size="10" multiple="multiple" style="width: 175px"
onChange="var v=\'\';o=this.options; for(var i=0;i<o.length;i++) if(o[i].selected)v+=\',\'+
and the hidden field might be something like this:
<input type="hidden" name="GenDisClassComb" id="GenDisClassComb" value="" />
ASKER
Zvonko: the page is cnstructed dynamicaly so if you do a page source it shows the original line code
but did a varable drop out and here is the code
********************* does not work ***************** see below for alert that does work
\t<select size="10" multiple="multiple" style="width: 175px"\n\t\t\tonChange="va r v="",o=this.options;\n\t\t for(var i=0;i<o.length;i++)\n\t\t if(o[i].selected)v+=","+o[ i].value;\ n\t\t this.form.DiseasesModeledC omb.value= v.substr(1 );"\t\n\n\ t\t\n\t\t\ n\t\t\n\t\ t\n\t\t><o ption value='anaemia'>anaemia</o ption><opt ion value='aneurysm'>aneurysm< /option><o ption value='angina'>angina</opt ion><optio n value='arrhythmia'>arrhyth mia</optio n><option value='arteriosclerosis'>a rterioscle rosis</opt ion><optio n value='cardiac arrest'>cardiac arrest</option><option value='cardiac tumour'>cardiac tumour</option><option value='cardiomyopathy'>car diomyopath y</option> <option value='congestive heart failure'>congestive heart failure</option><option value='Deep Vein thrombosis'>Deep Vein thrombosis</option><option value='DVT'>DVT</option><o ption value='embolism'>embolism< /option><o ption value='heart valve disease'>heart valve disease</option><option value='hypertension'>hyper tension</o ption><opt ion value='hypotension'
************************ this works with the alert ************************** **
\t<select size="10" multiple="multiple" style="width: 175px"\n\t\t\tonchange=" alert()";\t\n\n\t\t\n\t\t\ n\t\t\n\t\ t\n\t\t><o ption value='anaemia'>anaemia</o ption><opt ion value='aneurysm'>aneurysm< /option><o ption value='angina'>angina</opt ion><optio n value='arrhythmia'>arrhyth mia</optio n><option value='arteriosclerosis'>a rterioscle rosis</opt ion><optio n value='cardiac arrest'>cardiac arrest</option><option value='cardiac tumour'>cardiac tumour</option><option value='cardiomyopathy'>car diomyopath y</option> <option value='congestive heart failure'>congestive heart failure</option><option value='Deep Vein thrombosis'>Deep Vein thrombosis</option><option value='DVT'>DVT</option><o ption value='embolism'>embolism< /option><o ption value='heart valve disease'>heart valve disease</option><option value='hypertension'>hyper tension</o ption><opt ion value='hypotension'>hypote nsion</opt ion><optio n value='myocarditis'>myocar ditis</opt ion><optio n value='pernicious anaemia'>pernicious anaemia</option><option value='rheumatic heart disease'>rheumatic
but did a varable drop out and here is the code
********************* does not work ***************** see below for alert that does work
\t<select size="10" multiple="multiple" style="width: 175px"\n\t\t\tonChange="va
************************ this works with the alert **************************
\t<select size="10" multiple="multiple" style="width: 175px"\n\t\t\tonchange=" alert()";\t\n\n\t\t\n\t\t\
ASKER
neorush:
have placed the field
<input type="hidden" name="GenDisClassComb" id="GenDisClassComb" value="" />
is on the page and is between the page format
wil try on return to enter known data into the field to tet that way
have placed the field
<input type="hidden" name="GenDisClassComb" id="GenDisClassComb" value="" />
is on the page and is between the page format
wil try on return to enter known data into the field to tet that way
ASKER
it is trying to update a form element with name "GenDisClassComb" Most of the time this is something like a hidden field. You could try using document.getElementById() and make sure the field you are trying to update has a unique id so the code would change to this:
have the text set up it runs and no errors but still does not update the text field
have the text set up it runs and no errors but still does not update the text field
I noticed that the next example you gave used "DiseasesModeledComb" as the name of the field to update...if the field does not exist it can not be updated. Here is a simple example of what has to be in place for this to work:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html><head><title>TEST</title></head>
<body>
<form name="testForm">
<select size="10" multiple="multiple" style="width: 175px" onChange="var v='';o=this.options; for(var i=0;i<o.length;i++) if(o[i].selected)v+=','+o[i].value;this.form.DiseasesModeledComb.value=v.substr(1);">
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
<option value="4">Option 4</option>
<option value="5">Option 5</option>
</select>
<input type="text" name="DiseasesModeledComb" value="NOT UPDATED YET" />
</form>
</body>
</html>
The text is not HTML.
Can you perhaps save the complate HTML page from browser and apload the text file to EE?
Can you perhaps save the complate HTML page from browser and apload the text file to EE?
ASKER
can you have 2 on load events cause what you said makes sense,
the test code in the html page still has the onchange, cascade event, were what is required is the cascade event as well as updatign the text box, i am now in the process of testing the txt box for data adding to make sure that that is right.
the page has in fo in it that my clients woudl not want out there but i will build a cut down replicia and place that up, and psuh the question along.
again can i have a statment
onchange pt 1
onchange pt 2
so 2 different functions for an on change event, then i could add the present data to the txt box.
i willalso try a littl bit of on screen java to add the code to the box to allow me to test the select box as well as the txt box and then go from there
thanks for all your help so far
garry
the test code in the html page still has the onchange, cascade event, were what is required is the cascade event as well as updatign the text box, i am now in the process of testing the txt box for data adding to make sure that that is right.
the page has in fo in it that my clients woudl not want out there but i will build a cut down replicia and place that up, and psuh the question along.
again can i have a statment
onchange pt 1
onchange pt 2
so 2 different functions for an on change event, then i could add the present data to the txt box.
i willalso try a littl bit of on screen java to add the code to the box to allow me to test the select box as well as the txt box and then go from there
thanks for all your help so far
garry
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
$ret .= '<select size="10" multiple="multiple" style="width: 175px" name="srchlookstate_provin cedis"
onchange=" alert(this.form.name=srchl ookstate_p rovincedis .value);" >';
this wil now retreive the value of the box its self so the reload is working and i can see the box an display the values
YET THE BELOW CODE THAT EXTRACTS THE VALUE AND PACES IN ANOTHER TEXTBOX WILL NOT PHASE AND IS NOT SYNTAX CORRECT. HAVE PLACED IMAGE OF DEBUG CODE
$ret .= '<select size="10" multiple="multiple" style="width: 175px" name="srchlookstate_provin cedis"
onChange='var v="",o=this.options;
for(var i=0;i<o.length;i++)
if(o[i].selected)v+=","+o[ i].value;
this.form.CellEffectsMonCo mb.value=v .substr(1) '; >
cascade-orror.png
onchange=" alert(this.form.name=srchl
this wil now retreive the value of the box its self so the reload is working and i can see the box an display the values
YET THE BELOW CODE THAT EXTRACTS THE VALUE AND PACES IN ANOTHER TEXTBOX WILL NOT PHASE AND IS NOT SYNTAX CORRECT. HAVE PLACED IMAGE OF DEBUG CODE
$ret .= '<select size="10" multiple="multiple" style="width: 175px" name="srchlookstate_provin
onChange='var v="",o=this.options;
for(var i=0;i<o.length;i++)
if(o[i].selected)v+=","+o[
this.form.CellEffectsMonCo
cascade-orror.png
ASKER
have been trying to get a html page dump, but because the code does not run it cannot build its self with the code to look at
ASKER
have included the html page drop out, but it does get a bit conveluted, as the system goes through several php files a few functions and a tpl page to return the data for page display as well as the error.
i have attaced a word doc,
the incorrect code is in BLUE this is the code that does not work.
the code in red is from another box doing the same thing and works the only difference is the the red box is not driven of the top item select, were the one in blue requires dynamic java to rebuild the options table and then place the info in the listbox above.
hope this make it a bit more clear. have spent days on this problem and think that i am close.
advsearch-html-output.doc
i have attaced a word doc,
the incorrect code is in BLUE this is the code that does not work.
the code in red is from another box doing the same thing and works the only difference is the the red box is not driven of the top item select, were the one in blue requires dynamic java to rebuild the options table and then place the info in the listbox above.
hope this make it a bit more clear. have spent days on this problem and think that i am close.
advsearch-html-output.doc
ASKER
easy follow on question if your interesed still on the same issue just quick question about a line of code
https://www.experts-exchange.com/questions/26509070/'-srchlookstate-province-'-php-what-does-this-do.html
https://www.experts-exchange.com/questions/26509070/'-srchlookstate-province-'-php-what-does-this-do.html
ASKER
would it help if i put up a small site to show you what was happening coudl i get some one to have a look and see what i am missing is that possible
ASKER
thanks for all the help. has taken me a long way down the track, and will have more indepth questions down the track
as i have now a better idea on what isrequired
as i have now a better idea on what isrequired
Like this:
onchange=" alert(42);"