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.substr(1)';

            
sydneyguyAsked:
Who is Participating?
 
neorushCommented:
You had several syntax problems, this should work:
$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.substr(1);">';

To see the values for testing you could use 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;alert(v.substr(1));">';
0
 
ZvonkoSystems architectCommented:
You need something to alert().

Like this:

onchange="  alert(42);"

 

0
 
sydneyguyAuthor Commented:
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.substr(1)';

its used in the context as below building the $ret .= '

function DiseasesModeledBuild($countrycode) {
      global $config;
      if ( ($config['accept_country'] == '1' || $config['accept_country'] == 'Y' )  && $countrycode == 'AA' )  {
            return '<input name="srchlookstate_provincedis" type="text" class="textinput" size="30" maxlength="100" />';
      }
      $ret = '';
      $data = DiseasesModeled(trim($countrycode),'N');
      if (count($data) < 1) return '<input name="srchlookstate_provincedis" 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,this.form.srchlookcountry.value);" */
      }
      /* $ret .= '<option value="AA">'.get_lang('select_organtissue').'</option>'; */

      foreach ($data as $k => $y){
            if ($k != 'AA') {
                  $ret .= "<option value='$k'>$y</option>";
            }
      }
      unset ($data);

      return $ret .= '</select>';

}
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
sydneyguyAuthor Commented:
$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.substr(1)"; >';

THIS IS THE CORRECT SYNTAX WHICH WILL COMPILE AND RUN BUT WILL NOT RUN THE ONCHANGE FUNCTION
0
 
sydneyguyAuthor Commented:
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
0
 
ZvonkoSystems architectCommented:
Look in the browser resulting html text and you will see whether you get single " instead of "" and so on.

0
 
neorushCommented:
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.getElementById(\'GenDisClassComb\').value=v.substr(1);">';

and the hidden field might be something like this:
<input type="hidden" name="GenDisClassComb" id="GenDisClassComb" value="" />
0
 
sydneyguyAuthor Commented:
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="var 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.DiseasesModeledComb.value=v.substr(1);"\t\n\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t><option value='anaemia'>anaemia</option><option value='aneurysm'>aneurysm</option><option value='angina'>angina</option><option value='arrhythmia'>arrhythmia</option><option value='arteriosclerosis'>arteriosclerosis</option><option value='cardiac arrest'>cardiac arrest</option><option value='cardiac tumour'>cardiac tumour</option><option value='cardiomyopathy'>cardiomyopathy</option><option value='congestive heart failure'>congestive heart failure</option><option value='Deep Vein thrombosis'>Deep Vein thrombosis</option><option value='DVT'>DVT</option><option value='embolism'>embolism</option><option value='heart valve disease'>heart valve disease</option><option value='hypertension'>hypertension</option><option 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><option value='anaemia'>anaemia</option><option value='aneurysm'>aneurysm</option><option value='angina'>angina</option><option value='arrhythmia'>arrhythmia</option><option value='arteriosclerosis'>arteriosclerosis</option><option value='cardiac arrest'>cardiac arrest</option><option value='cardiac tumour'>cardiac tumour</option><option value='cardiomyopathy'>cardiomyopathy</option><option value='congestive heart failure'>congestive heart failure</option><option value='Deep Vein thrombosis'>Deep Vein thrombosis</option><option value='DVT'>DVT</option><option value='embolism'>embolism</option><option value='heart valve disease'>heart valve disease</option><option value='hypertension'>hypertension</option><option value='hypotension'>hypotension</option><option value='myocarditis'>myocarditis</option><option value='pernicious anaemia'>pernicious anaemia</option><option value='rheumatic heart disease'>rheumatic
0
 
sydneyguyAuthor Commented:
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
0
 
sydneyguyAuthor Commented:
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
0
 
neorushCommented:
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>

Open in new window

0
 
ZvonkoSystems architectCommented:
The text is not HTML.
Can you perhaps save the complate HTML page from browser and apload the text file to EE?
0
 
sydneyguyAuthor Commented:
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
0
 
ZvonkoSystems architectCommented:
You can alwasy do this:
<some html tags for your select and other html tags>
  <more tags>
</last tag of objects that you want to acces in your script>
<script>
function thatAccessUpperTags(){
  alert(42);
}
 thatAccessUpperTags();
</script>

That mean that you do not need to use onLoad event handler to test some script.
You can place anywhere on the page but always below the last tag that you want to use in your script.
For example placing additional script with function definitions andfunction calls is best done at the bottom of the html page because all tags are loaded at that page location.

And please post your HTML page source for more help.


0
 
sydneyguyAuthor Commented:
$ret .= '<select size="10" multiple="multiple" style="width: 175px" name="srchlookstate_provincedis"
               onchange=" alert(this.form.name=srchlookstate_provincedis.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_provincedis"
               onChange='var v="",o=this.options;
                            for(var i=0;i<o.length;i++)
                            if(o[i].selected)v+=","+o[i].value;
                            this.form.CellEffectsMonComb.value=v.substr(1)'; >


cascade-orror.png
0
 
sydneyguyAuthor Commented:
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
0
 
sydneyguyAuthor Commented:
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
0
 
sydneyguyAuthor Commented:
easy follow on question if your interesed still on the same issue just quick question about a line of code
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_26509070.html
0
 
sydneyguyAuthor Commented:
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
0
 
sydneyguyAuthor Commented:
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
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.