Jump to content

reptile

Members
  • Posts

    19
  • Joined

  • Last visited

reptile's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks KevinM1, I will attempt to dig deeper into the source code and will let you know.
  2. Hmm... I see, I do know that once the page loads and then you select different selections in the dropdown (eg. Select distinct Division...) then the other dropdowns change because they depend on that select statement from the database. I just can't get the one to work where 'Select Style' selects a style and then it should change the 'Select Front' selections or at least display them which it's not.
  3. Yeah, there might be more to it. PHP isn't something that I have much experience with but this is existing code that I have to modify at work. Basically this code generates dropdown menus with data, so whenever a change is made in the selection then the function is called to display data in the other dropdown menus. But the updateforBodyfitting isn't working. So the "Select Front" changes depending on the selection in the "Select Style".
  4. PHP scripts will only be activated when a request is made to the webserver and will cause a page to refresh, so from javscript's onchange event. But I am just annoyed because one function is called while the other isn't, there is nothing different in the way they are being called.
  5. Maybe I said it incorrectly then but both functions are being called by the browser. Both at different "Onchange" events. Also yes I know that javascript works on the browser and php on the webserver.
  6. I see what you are saying, but how come the function "updateSelectClothByDiv(division)" is being called, this is also an onchange event?
  7. Hi, I've highlighted the code in red below, it is not showing the output, although it does show the results when I view the source of the actual webpage (so looks to work), it should show a dropdown menu beginning with 'Select Front' but I am getting an "objected expected" error, also this function "Updateforbodyfittingoptions" is called at the onchange event.
  8. I have a dropdown menu created from javascript, so the onchange event should call a function called updateForBodyfittingoptions(). The thing here is that this function updateForBodyfittingoptions() should actually run dependent on a loop that is part of another function called UpdateDivision. So if I were to put the function UpdateBodyfitting directly within the loop of the other function updateSelectClothByDiv(division) then I get "Object Expected". Remember the onchange calls the UpdateBodyfitting function. Here is the code which I've shortened for purposes of posting on here, I've also attached the main php file with all the code just in case anyone wants to reference it. , the main function is "generateUpdateSelectClothByDiv", within this function are "updateForBodyfittingoptions" and "updateSelectClothByDiv(division)". Really appreciate any help I can get, thanks in advance. function generateUpdateSelectClothByDiv() { global $connect,$hriconnect,$division_array,$cloth_array,$lining_array,$lining_sleeve_array,$bodyfitting_array,$pantstyle_array,$veststyle_array,$glob_div; $indexdiv=1; $indexbody=1; //global $field1_array,$field2_array,$field4_array,$extras_array,$field5_array; // echo "\t\tdocument.pickDivision.bodyfitting.selectedIndex=-1;\n"; $cloth_numrows = 0; $clothArray = array(); $div_query = "SELECT distinct DIVISION, CLOTHDB FROM MTM_DIVISIONS_S ORDER BY CLOTHDB"; $div_result = oci_parse($connect,$div_query); oci_execute($div_result); while ($div_row = oci_fetch_array($div_result, OCI_ASSOC)) { $divArray[] = "{$div_row['CLOTHDB']}"; $divDivArray[] = "{$div_row['DIVISION']}"; } oci_free_statement($div_result); // print("//TEST\n\n"); echo "\tfunction updateSelectClothByDiv(division)\n"; echo "\t{\n"; $first = 0; echo "\tClearOptionsFastAlt('cloth');\n"; echo "\t\tdocument.pickDivision.textInput.value='';\n"; echo "var divcomp = division.replace(/^\s+|\s+$/g, '');"; //echo "alert(divcomp)"; for ($i = 0; $i < sizeof($divArray); $i++) { $cloth_query="SELECT CLOTH, CODE FROM ".$divArray[$i]." where CODE <>'OUT' or CODE is null ORDER BY cloth"; $cloth_result = oci_parse($connect,$cloth_query); oci_execute($cloth_result); $cloth_numrows = count_rows($connect,$cloth_query); $maxclothrows=$cloth_numrows+1; $bodyfitting_query="SELECT BODYFITTING, BFCODE FROM MTM_STYLES_S WHERE DIVISION= '".$divDivArray[$i]."' AND STYLE_TYPE='BODY' GROUP BY BODYFITTING, BFCODE ORDER BY BODYFITTING"; $bodyfitting_result = oci_parse($connect,$bodyfitting_query); oci_execute($bodyfitting_result); $bodyfitting_numrows = count_rows($connect,$bodyfitting_query); $maxclothrows=$bodyfitting_numrows+1; if($first == 0) { $first++; } else { echo "\telse\t"; } //echo "\talert('$divArray[$i]' +' '+ '$divDivArray[$i]'+' :aaa:' + divcomp);"; echo "\tif (divcomp == \"{$divDivArray[$i]}\") {"; $y=1; echo "var selectObj = document.pickDivision.cloth;\n"; echo "var numShown = selectObj.options.length;\n"; echo "selectObj.selectedIndex = -1;\n"; echo "\t\t\tselectObj.options[numShown] = new Option('- Select Cloth -', '');\n"; echo "\t\t\tnumShown++;\n"; while ($cloth_row = oci_fetch_array($cloth_result, OCI_ASSOC)) { $newCloth=$cloth_row['CODE']; $newStyle=$cloth_row['CLOTH']; echo "\t\t\tselectObj.options[numShown] = new Option('".$newStyle.' '.$newCloth."', '".$newStyle."');\n"; echo "\t\t\tnumShown++;\n"; $y++; } echo "\t\t\tdocument.pickDivision.cloth.options[0].selected = true;\n\n"; echo "\tClearOptionsFastAlt('lining');\n"; echo "\t\tdocument.pickDivision.textInput.value='';\n"; echo "var divcomp = division.replace(/^\s+|\s+$/g, '');"; echo "var selectObj = document.pickDivision.lining;\n"; echo "var numShown = selectObj.options.length;\n"; echo "selectObj.selectedIndex = -1;\n"; echo "\t\t\tselectObj.options[numShown] = new Option('- Select Lining -', '');\n"; echo "\t\t\tnumShown++;\n"; while ($lining_row = oci_fetch_array($lining_result, OCI_ASSOC)) { $newLining=$lining_row['CLOTH']; echo "\t\t\tselectObj.options[numShown] = new Option('".$newLining."' ,'".$newLining."');\n"; echo "\t\t\tnumShown++;\n"; $y++; } echo "\t\t\tdocument.pickDivision.lining.options[0].selected = true;\n\n"; //Setup new dropdown for Style Selection echo "\tClearOptionsFastAlt('bodyfitting');\n"; echo "\t\tdocument.pickDivision.textInput.value='';\n"; echo "var divcomp = division.replace(/^\s+|\s+$/g, '');"; echo "var selectObj = document.pickDivision.bodyfitting;\n"; echo "var numShown = selectObj.options.length;\n"; echo "selectObj.selectedIndex = -1;\n"; echo "\t\t\tselectObj.options[numShown] = new Option('- Select Style -', '');\n"; echo "\t\t\tnumShown++;\n"; while ($bodyfitting_row = oci_fetch_array($bodyfitting_result, OCI_ASSOC)) { $newBodyfitting=$bodyfitting_row['BODYFITTING']; $newBfcode=$bodyfitting_row['BFCODE']; $bodyfitArray[] = "{$bodyfitting_row['BFCODE']}"; $bodyfitbodyarray[]="{$bodyfitting_row['BODYFITTING']}"; echo "\t\t\tselectObj.options[numShown] = new Option('".$newBfcode.' '.$newBodyfitting."', '".$newBfcode."');\n"; echo "\t\t\tnumShown++;\n"; $y++; echo "\tfunction updateForBodyfittingoptions()\n"; echo "\t{\n"; echo "\t\tif(document.pickDivision.bodyfitting.options.value == '{$bodyfitting_row['BFCODE']} {$bodyfitting_row['BODYFITTING']}')\n"; echo "\t\t{\n"; //Show selection for front $field1_query = "SELECT MTM_STYLES_S.CODE,MTM_SUFFEX_S.TEXT FROM MTM_STYLES_S,MTM_SUFFEX_S WHERE MTM_SUFFEX_S.DIVISION='".$divDivArray[$i]."' AND (MTM_STYLES_S.FIELD=MTM_SUFFEX_S.FIELD AND MTM_STYLES_S.CODE=MTM_SUFFEX_S.CODE) AND MTM_STYLES_S.STYLE_TYPE='BODY' AND MTM_STYLES_S.BODYFITTING='".$bodyfitting_row['BODYFITTING']."' AND MTM_STYLES_S.FIELD=1 ORDER BY MTM_STYLES_S.FIELD,MTM_STYLES_S.CODE"; $field1_result = oci_parse($connect,$field1_query); oci_execute($field1_result); echo "\t\t\tdocument.pickDivision.field1.options[0].value = '';\n"; echo "\t\t\tdocument.pickDivision.field1.options[0].text = '- Select Frontaaa';\n\n"; $y=1; while ($field1_row = oci_fetch_array($field1_result, OCI_ASSOC)) { $newField1=$field1_row['TEXT']; $newField1Code=$field1_row['CODE']; $bodyfitArray[] = "{$bodyfitting_row['BFCODE']}"; $bodyfitbodyarray[]="{$bodyfitting_row['BODYFITTING']}"; echo "\t\t\tselectObj.options[numShown] = new Option('".$newField1Code.' '.$newField1."', '".$newField1Code."');\n"; echo "\t\t\tnumShown++;\n"; $y++; } echo "\t\t\tdocument.pickDivision.field1.options[0].selected=true;\n\n"; $indexfield1=1; oci_free_statement($field1_result); echo "\t\t}\n\n"; echo "\t\t}\n\n"; } echo "\t\t\tdocument.pickDivision.bodyfitting.options[0].selected=true;\n\n"; echo "\t}\n\n"; oci_free_statement($bodyfitting_result); $indexbody=1; oci_free_statement($cloth_result); } $indexdiv++; echo "\t\treturn true;\n"; echo "\t}\n\n"; oci_close($connect); } mtm.php
  9. Hello everyone, I am having a pretty basic problem. Below is a piece of my code, the first few lines of "Get Value for Bodyfitting" basically gets a value and assigns it to some variables through a select statement (this later on you will see that the values are being shown through echo on the screen in a form of a javascript dropdown for "Style Selection"), now the second few lines is where I have some issues in the "Value for Field 1", I want to get back a value by getting the answer from the first sql but I can't get the value for "$newBodyfitting" because it is only assigned later on, this will allow me to get a dropdown for a "Select Front", this is dependent on the "Select Style" if you see below, I know it might sound confusing. Thanks in advance. //Get Division $div_query = "SELECT distinct DIVISION, CLOTHDB FROM MTM_DIVISIONS_S ORDER BY CLOTHDB"; $div_result = oci_parse($connect,$div_query); oci_execute($div_result); while ($div_row = oci_fetch_array($div_result, OCI_ASSOC)) { $divArray[] = "{$div_row['CLOTHDB']}"; $divDivArray[] = "{$div_row['DIVISION']}"; } oci_free_statement($div_result); //Get Value for Bodyfitting $bodyfitting_query="SELECT BODYFITTING, BFCODE FROM MTM_STYLES_S WHERE DIVISION= '".$divDivArray[$i]."' AND STYLE_TYPE='BODY' GROUP BY BODYFITTING, BFCODE ORDER BY BODYFITTING"; $bodyfitting_result = oci_parse($connect,$bodyfitting_query); oci_execute($bodyfitting_result); //Get Value for Field1 $field1_query="SELECT MTM_STYLES_S.CODE,MTM_SUFFEX_S.TEXT FROM MTM_STYLES_S,MTM_SUFFEX_S WHERE MTM_SUFFEX_S.DIVISION='".$divDivArray[$i]."' AND (MTM_STYLES_S.FIELD=MTM_SUFFEX_S.FIELD AND MTM_STYLES_S.CODE=MTM_SUFFEX_S.CODE) AND MTM_STYLES_S.STYLE_TYPE='BODY' AND MTM_STYLES_S.BODYFITTING='".$newBodyfitting."' AND MTM_STYLES_S.FIELD=1 ORDER BY MTM_STYLES_S.FIELD,MTM_STYLES_S.CODE"; $field1_result = oci_parse($connect,$field1_query); oci_execute($field1_result); //Setup new dropdown for Style Selection echo "\tClearOptionsFastAlt('bodyfitting');\n"; echo "\t\tdocument.pickDivision.textInput.value='';\n"; echo "var divcomp = division.replace(/^\s+|\s+$/g, '');"; echo "var selectObj = document.pickDivision.bodyfitting;\n"; echo "var numShown = selectObj.options.length;\n"; echo "selectObj.selectedIndex = -1;\n"; echo "\t\t\tselectObj.options[numShown] = new Option('- Select Style -', '');\n"; echo "\t\t\tnumShown++;\n"; while ($bodyfitting_row = oci_fetch_array($bodyfitting_result, OCI_ASSOC)) { $newBodyfitting=$bodyfitting_row['BODYFITTING']; $newBfcode=$bodyfitting_row['BFCODE']; echo "\t\t\tselectObj.options[numShown] = new Option('".$newBfcode.' '.$newBodyfitting."', '".$newBfcode."');\n"; echo "\t\t\tnumShown++;\n"; $y++; } //Setup dropdown new Front dependent on Style above echo "\t\t\tdocument.pickDivision.bodyfitting.options[0].selected = true;\n\n"; echo "\t\tdocument.pickDivision.field1;\n"; echo "\tClearOptionsFastAlt('field1');\n"; echo "\t\tdocument.pickDivision.textInput.value='';\n"; echo "var divcomp = division.replace(/^\s+|\s+$/g, '');"; echo "var selectObj = document.pickDivision.field1;\n"; echo "var numShown = selectObj.options.length;\n"; echo "selectObj.selectedIndex = -1;\n"; echo "\t\t\tselectObj.options[numShown] = new Option('- Select Front -', '');\n"; echo "\t\t\tnumShown++;\n"; while ($field1_row = oci_fetch_array($field1_result, OCI_ASSOC)) { $newField1=$field1_row['TEXT']; $newField2=$field2_row['CODE']; echo "\t\t\tselectObj.options[numShown] = new Option('".$newField1.''.$newField2."');\n"; echo "\t\t\tnumShown++;\n"; $y++; } echo "\t\t\tdocument.pickDivision.field1.options[0].selected=true;\n\n"; oci_free_statement($field1_result); oci_free_statement($bodyfitting_result);
  10. Your logic seems correct for sure, unfortunately it's not working for me so there has to be more to it in the code, yours does work just not in my program because as Josh mentioned there seems to be more afterwards. I've put code in my previous post where values are inserted from the database.
  11. This is part of another while loop, but the basic code is here to print all the cloth selections dependent on the division (option the user can choose, there are 2 to choose from). // Print all cloth choices for the given division $cloth_query = "SELECT cloth,code FROM ".strtolower($division_row['CLOTHDB'])." ORDER BY CLOTH"; $cloth_result = oci_parse($connect,$cloth_query); oci_execute($cloth_result); $cloth_numrows = count_rows($connect,$cloth_query); echo "\t\t\tdocument.pickDivision.cloth.options[0].value = '';\n"; echo "\t\t\tdocument.pickDivision.cloth.options[0].text = '- Select Cloth -';\n\n"; $y=1; while ($cloth_row = oci_fetch_array($cloth_result, OCI_ASSOC)) { $clothArray[] = "{$cloth_row['CLOTH']}"; $cloth_array[$indexdiv][$indexcloth]="{$cloth_row['CLOTH']} {$cloth_row['CODE']}"; echo "\t\t\tdocument.pickDivision.cloth.options[$y].value = '{$cloth_row['CLOTH']} {$cloth_row['CODE']}';\n"; echo "\t\t\tdocument.pickDivision.cloth.options[$y].text = '{$cloth_row['CLOTH']} {$cloth_row['CODE']}';\n\n"; $y++; $indexcloth++; }
  12. I did but still no luck, appreciate your help though so far.
  13. Anymore ideas by anyone please? I'm still hammering away at this...
  14. Thanks for your help thus far, that would be extremely easy to exclude nulls, the problem is this. The dropdown list is dependent on an option selection. 2 options for example, A and B. If the user selects option A then lets say there are a max# of cloths that are brought back at 20. Now when the user selects option B then max# of cloths brought back are 15. So this is coded in a way that because option A has 5 more values then option B, to clear those extra values of option A away when option B is selected, those extra 5 values are nulled out or set to ' '. This is the point where I would like to remove those extra 5 blank lines from the dropdown. Hope that made sense?
  15. Sorry Josh again for not being too clear, what I mentioned to Cracka Memba above is what I want to do.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.