Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Senior Coder
    Join Date
    Jul 2003
    Location
    My pimped-out igloo in Canadia
    Posts
    1,966
    Thanks
    36
    Thanked 0 Times in 0 Posts

    Cool can i create an array to hold the paths of various files?

    Hey.

    Say i had a dynamic menu (selection in menu 1 defines the values shown in menu 2).

    like so:
    FULL FIXED, FUNCTIONAL CODE
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <SCRIPT language=JavaScript type=text/JavaScript>
    <!--
    
    var Start_Array = new Array("Then choose a corresponding product");
    var Null_Array = new Array("");
    var Bindicator_Array = new Array("Now please select the desired product","--------------------------->","Phase Tracking Continuous level monitoring (Dry and Liquids)","Load Cells","Yo Yos");
    var Greyline_Array = new Array("Now please select the desired product","--------------------------->","Ultrasonic Level Transmitters and Switches","Pump Station Level Control","Ultrasonic Tank Farm Level Systems","Open Channel Flow Monitors","Area-Velocity flow meters","Doppler Flow Meters","Transit Time flow meters");
    var Intempco_Array = new Array("Now please select the desired product","--------------------------->","Temperature sensors (RTD\'s, Thermocouples, Thermowells)","Temperature transmitters; wire and connectors","RF Capacitance Level Switch and continuous probes","Humidity Sensors and Controllers, Wet bulb/Dry bulb","Data Acquisition");
    var ITSnull_Array = new Array("");
    var Babbit_Array = new Array("Now please select the desired product","--------------------------->","RF and Ultrasound Level switches","Broken Bag Detectors");
    var Eurotron_Array = new Array("Now please select the desired product","--------------------------->","Calibrators (for Tc, RTD, ohms, mV, mA, V)","Combustion gas analyzers","Sample conditioners","Infrared thermometers");
    var Smar_Array = new Array("Now please select the desired product","--------------------------->","Temperature and pressure transmitters (4/20+Hart+FIELDBUS), PLCs");
    var Multifor_Array = new Array("Now please select the desired product","--------------------------->","Circuit board manufacturing - prototypes and small quantities. -> Fast delivery.","Thru-hole to surface mount conversion. Assembly available");
    var Scaletron_Array = new Array("Now please select the desired product","--------------------------->","Silo weighing - load cells and strain guages","Batch control systems for dry bulk and liquid mixtures","RadarTron microwave moisture sensor for granular materials","Avanti concrete mixer","Crane Scales","Pallet Scales","Counting Scales");
    var SivaNull_Array = new Array("");
    var Chino_Array = new Array("Now please select the desired product","--------------------------->","Analog and hybrid temperature recorders and controllers","Radiation Thermometers");
    var Delta_Array = new Array("Now please select the desired product","--------------------------->","Emission monitors","Dewpoint","Calorimeters","On-Line Liquid Analyzers");
    var HayesClevland_Array = new Array("Now please select the desired product","--------------------------->","Programmable Controllers and Loop Controllers");
    var Indumart_Array = new Array("Now please select the desired product","--------------------------->","Bar graph indicators with relays and RS-232 and 4-20mA retransmitters.","Pressure gauges and transmitters","Thermometers","Signal conditioning","Pneumatic controller and recorder");
    var JUMO_Array = new Array("Now please select the desired product","--------------------------->","PH/Redox: Sensors, Transmitters, and Controllers","Dissolved oxygen measurement","CL / CL02 ozone and hydrogren peroxide measurement");
    var Reigl_Array = new Array("Now please select the desired product","--------------------------->","Laser distance sensors","2D & 3D Scanners");
    var Siva_Array = new Array("Now please select the desired product","--------------------------->","Valve manifolds:","-> 1 to 5 valve","-> Needle","-> Ball and gauge manifolds","-> Headers");
    var TTI_Array = new Array("Now please select the desired product","--------------------------->","Calibration Equipment","Emissions control and montitoring","Data Loggers"," ","Fuji","------->","Transit time flow meters - fixed and portable","Chart recorders","Controllers");
    var MiscNull_Array = new Array("");
    var Bebco_Array = new Array("Now please select the desired product","--------------------------->","Enclosure Protection Systems","Building Pressurization Systems","Purged Industrial Shelters","Wall Mounted Air Conditioning");
    var HaxPneumatics_Array = new Array("Now please select the desired product","--------------------------->","Dry bulk flow controllers","Gain-in-Weight and Loss-in-Weight feeders","Non contact Motion Meter");
    var PrecisionDigital_Array = new Array("Now please select the desired product","--------------------------->","Digital Panel Meters - Universal Process Meter","mV Meter","Flow totalizer & Tachometer/Rate Meter","Loop-powered meters","4 Point annunciator");
    var Proceco_Array = new Array("Now please select the desired product","--------------------------->","Parts washers");
    var Reimelt_Array = new Array("Now please select the desired product","--------------------------->","Silos","Discharge systems","Bagging equipment","Conveying, Metering, Grinding, Shifting, and Weighing equipment","Automation");
    var Sirco_Array = new Array("Now please select the desired product","--------------------------->","Indoor Stationary water samplers","Outdoor Stationary water samplers","Portable water samplers");
    var Strongwell_Array = new Array("Now please select the desired product","--------------------------->","Fiberglass (FRP) structures and systems:","-> Fiberglass Gritted Plate","-> Fiberglass Structures","-> Fiberglass Structural Shapes and Plate","-> Fiberglass Gratings","-> Molded Fiberglass Gratings","-> Fiberglass Handrails and Ladders","-> Fiberglass Studs and nuts","-> Fiberglass Building panels","-> Foam Core Building panels","-> Fiberglass Flooring and decking","-> Baffle Panels");
    
    
    function refill_Product(objProducer) {
      var objProduct = objProducer.form.Product;
      var selectedArray  = window[objProducer.options[objProducer.selectedIndex].value.replace(/\s/g,'') + "_Array"];
      objProduct.options.length = 0;
      for (var i=0; i < selectedArray.length; i++) {
        objProduct.options[i]=new Option(selectedArray[i], selectedArray[i].replace(/->\s/g, ""));
      }
    }
    
    // End -->
    </script>
    
    </head>
    
    <body onload="refill_Product(document.productchoice.Producer)">
    <form name="productchoice">
    
    <select name="Producer" onchange="refill_Product(this)">
    <option value="Start">Please choose a company</option>
                <option value=Null>---------------------------------------></option>
                <option value="Bindicator">Bindicator (Celtek Electronics)</option>
                <option value="Greyline">Greyline<\/option>
                <option value="Intempco">Intempco Controls</option>
                <option value=ITSnull>ITS</option>
                <option value="Babbit"> -> Babbit</option>
                <option value="Eurotron"> -> Eurotron</option>
                <option value="Smar"> -> Smar</option>
                <option value="Multifor">Multifor</option>
                <option value="Scaletron">Scaletron</option>
                <option value=SivaNull>Siva</option>
                <option value="Chino"> -> Chino</option>
                <option value="Delta"> -> Delta</option>
                <option value="Hayes Clevland"> -> Hayes Clevland</option>
                <option value="Indumart"> -> Indumart</option>
                <option value="JUMO"> -> JUMO</option>
    			<option value="Reigl"> -> Reigl</option>
    			<option value="Siva"> -> Siva</option>
                <option value="TTI"> -> TTI</option>
    			<option value=MiscNull>Misc.</option>
                <option value="Bebco"> -> Bebco</option>
                <option value="Hax Pneumatics"> -> Hax Pneumatics</option>
                <option value="Precision Digital"> -> Precision Digital</option>
    			<option value="Proceco"> -> Proceco</option>
                <option value="Reimelt"> -> Reimelt</option>
    			<option value="Sirco"> -> Sirco</option>
    			<option value="Strongwell"> -> Strongwell</option>
    </select>
    <p>
            <select name="Product" onChange="" size="1" style="width:450; background-color: white;" tabindex="2">
                <!-- option value=""><-----------</option -->
            </select>
    </form>
    </body>
    </html>
    And say i wanted to display a link based on the value selected in menu 2

    like so:
    Code:
    function openInfo(objProduct){
      var optVal = objProduct.options[objProduct.selectedIndex].value;
      if (optVal != " " && optVal.indexOf("------->") == -1){
         optVal = optVal.replace(/(\s)|(\/)/g, "_"); 
         var win = window.open("info/" + optVal + "_info.htm", "infoPop", "toolbar=0, width=475, height=200, left=300, top=300");
         win.focus();
      }
      else alert("Please choose a product.");
      return false;
    }
    ...
    <select name="Product" ...>
    ...
    </select>
    <input type="button" value="More Info" onclick="openInfo(this.form.Product)" />
    <a href="#" onclick="return openInfo(document.productchoice.Product)">More Info</a>
    I'd be happy.
    The only issue would be that according to the script above, i would have to name my links as follows:

    Phase Tracking Continuous level monitoring (Dry and Liquids)
    would have to be
    Phase_Tracking_Continuous_level_monitoring_(Dry_and_Liquids)_info.htm

    ...

    all fine and dandy i suppose.

    That being said, it would be EXTREMELY advantageous to me if i could do the following:

    instead of having to name each file according to the menu... i propose the following. Can i have the script above which displays the link based on the 2nd menu selection GRAB the path of the file from an array?

    like so:
    Code:
    var url {
      
      "Phase Tracking Continuous level monitoring (Dry and Liquids)".src = info/phase.htm;
      "Ultrasonic Level Transmitters and Switches".src = info/ultrasonic.htm;
      "...etc"
    }
    How would i do this? How would i modify the middle script to look for the path of the file in the array url

    Thanks a lot in advance. And especially, thanks to those who've gotten me this far
    Last edited by canadianjameson; 11-10-2004 at 12:36 AM.
    Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)

  • #2
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You would do yourself a favor if you would post example code that was ready to run.... I looked into trying to help you but your first example is so full of errors that I quickly lost interest in not only fixing those errors but also even considering piecing together the rest of your script blocks into something that was workable to test with....

    But the short of it is yes... You could take the index value of the second array and use that to find the corresponding url in your link array...

    .....Willy

  • #3
    Senior Coder
    Join Date
    Jul 2003
    Location
    My pimped-out igloo in Canadia
    Posts
    1,966
    Thanks
    36
    Thanked 0 Times in 0 Posts
    hehe, i'm sorry Willy, i was in such a hurry i killed the code

    i works now

    Thanks again
    Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)

  • #4
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Firstly I do not understand what this highlighted in red is doing or what it is used for... I first thought it may be a value with the spaces removed (although why you would need to remove [ -> ] is also a mystery) but nowhere are you specifically assigning a value... Rather the value upon form submit default to the option text value (unless of course there is more to the script than you posted)....

    The reason I ask is it may be easier to add your url's to those new Options rather than creating another array...

    I also do not understand how you plan to fire the link to goto the new URL... onchange of the second option menu?

    objProduct.options[i]=new Option(selectedArray[i], selectedArray[i].replace(/->\s/g, ""));

  • #5
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I figured out what happened to your values being sent to the server when you submit the form... You broke the expression when you added -> to:
    objProduct.options[i]=new Option(selectedArray[i], selectedArray[i].replace(/->\s/g, ""));


    Anyways, I think this is what you are looking for:
    Code:
    <input type="button" value="GoTo Product URL" 
    onclick="if(this.form.Product.options.selectedIndex>1){
    (/(^\w+)(?=\s)/).test(this.form.Product[this.form.Product.options.selectedIndex].text);
    location.href='info/'+RegExp.$1.toLowerCase()+'.htm'}
    else{alert('Please choose a product')}">

    I'll let you fix the now broken expression yourself... Particularly since it makes no sense to me to remove those characters...


    .....Willy

  • #6
    Senior Coder
    Join Date
    Jul 2003
    Location
    My pimped-out igloo in Canadia
    Posts
    1,966
    Thanks
    36
    Thanked 0 Times in 0 Posts
    I took out the -> for one very specific reason.

    I use -> in my actual form (www.enviromark.ca/english/quoteform.html - select Strongwell for example) to delineate a subgroup of products. Now this form is sent to a success page and displayed in a neat printable format (as you've seen no doubt, if not submit the form.

    all that to say that without stripping out the "->", the Product part of the success page displays "-> This Product"

    here's what the two look like:
    Code:
    Without removal
    Producer: Strongwell
    Product:  -> Fiberglass Structures
    
    With removal
    Producer: Strongwell
    Product:  Fiberglass Structures
    with proper alignment, the second one is a lot more professional looking. Thats why i absolutely need to strip out the ->

    edit:

    by my own wish to not confuse the situation with more code, i had removed some of the options and their corresponding vars. i've re-edited the first post and put in ALL the products and their 2nd menu items. Sorry for that
    Last edited by canadianjameson; 11-10-2004 at 12:34 AM.
    Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)

  • #7
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The way you added those two characters breaks the expression when a value does not include those values but only has spaces... Essentially your expression says to remove the characters ->(space) if they appear in that order...

    what you are looking for is: replace(/[->\s]/g, ""))

    And I do not need to see any more of the option array values...
    The solution I provided should work for what you need without creating another array by simply using the option text value (can not use the value because theorticly you should be stripping out spaces I believe) and stripping out the very first word to be used as the file name...

    .....Willy

  • #8
    Senior Coder
    Join Date
    Jul 2003
    Location
    My pimped-out igloo in Canadia
    Posts
    1,966
    Thanks
    36
    Thanked 0 Times in 0 Posts


    yeah, i like it stripping out the space after the -> because... well.... its there and it wouldnt look right if it was kept. That being said i do appreciate the clarification because if i ever do need to modify that to remove another character, but not the space, it will come in handy

    as fot the script you provided... i like the idea, however the reason why i asked for an array was because the files i want to become the link based on the 2nd meenu choice are actually already created and named... some oddly.

    I may not be allowed to change all the filenames to the first word in the 2nd menu... which is why i wanted to have an array where i could use the pre-existing filenames and not rock the boat, so to speak (naming schemes & such).

    I know i'm being difficult Willy... I'm sorry.

    any chance we can modify the script to read from an array?

    Last edited by canadianjameson; 11-10-2004 at 01:59 AM.
    Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)

  • #9
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Why the **** does it need to read from an array when the solution I provide adhers to the example URL's you provided...

    Try looking beyond the narrow box you are peering out of and at least consider the solution I offered which does not require much more than one line of code...

    I bet you did not even try implementing my solution...
    In fact, I know you did not.... ****ing waste of my time....

  • #10
    Senior Coder
    Join Date
    Jul 2003
    Location
    My pimped-out igloo in Canadia
    Posts
    1,966
    Thanks
    36
    Thanked 0 Times in 0 Posts

    what in the blinking hell....

    Quote Originally Posted by Willy Duitt
    Why the **** does it need to read from an array when the solution I provide adhers to the example URL's you provided...
    very simply... it does not adhere to the example url's i've provided you. as previously stated the urls of the files ARE NOT the first words of the drop down menu value.
    Code:
    for example: 
    Producer: Sirco
    Product:  Portable Flow Meters
    
    the link to the actual product url is
    http://www.enviromark.ca/english/prodInfo/Sirco/PVS.htm
    your code, WHICH YES I DID ****ING RUN, generates this:
    http://www.enviromark.ca/english/info/portable.htm
    apart from the small change of info to prodInfo, the product dir needed to be included (not hard, i know), then the actual filename. a filename which cannot be the first name of the product in the menu because, well, hell, there are like 16 "portable" products.

    Quote Originally Posted by Willy Duitt
    Try looking beyond the narrow box you are peering out of and at least consider the solution I offered which does not require much more than one line of code...
    I considered it very hard Willy... contrary to your now obvious beleif i do not sit here plotting the best method to waste your time. I'm actually fairly insulted at the insinuation. I tested the code, did not find the solution was as flexible as i needed it to be, and suggested we proceeded down a different path. It's nice to know how your solution works, and i'm sure that for the next project i work on, that that approach will be the route to go.

    i do not consider your advice pithy and do not easily disregard it. I consider this whole situation to be a failure on my part, as it was obviously my poor explanation which put us here

    Quote Originally Posted by Willy Duitt
    I bet you did not even try implementing my solution...
    In fact, I know you did not.... ****ing waste of my time....
    I've addressed this above.

    You really needn't have taken this tone with me.

    I don't know what to say.
    Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)

  • #11
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by canadianjameson
    very simply... it does not adhere to the example url's i've provided you. as previously stated the urls of the files ARE NOT the first words of the drop down menu value.
    You provided two examples: phase.htm & ultrasonic.htm

    var url {

    "Phase Tracking Continuous level monitoring (Dry and Liquids)".src = info/phase.htm;
    "Ultrasonic Level Transmitters and Switches".src = info/ultrasonic.htm;
    "...etc"
    }
    Both of which are the first word of the option text albeit to lowerCase...

    So, yes, my snippet adhered exactly to the nomenculture that the only two examples you provided showed... Both phase & ultrasonic are the first word....

    True, my example did not use an array, but it also did not require extensive modification to your existing arrays and script.... Glenn pointed out how to use an array by making a 2 dimensional array in this thread where this question started and remained unresolved for quite some time (my very first response in this thread also pointed out that this was an option)....

    And although my snippet did not use arrays which you originally asked for, sometimes when asking for help you will find that someone will look at the problem differently and arrive at an alternative solution... I actually looked at your code while eating dinner and tried to find a way to do what you wanted without the need to make extensive modifications.... Perhaps if your example URL's more clearly showed differing URL's rather than the common denominator both shared of the first word, I may have done things differently....

    Eitherway, as a developer I would prefer to use a 1-2 line snippit and use the first word of the option as the file name (even if this required renaming a few files) than because of a lack of forethought, return and extensively modify my current arrays and the functions which use those arrays... But that is me, and of course you can do anything you like.... I just know better now than to offer you an alternative solution....

    .....Willy

  • #12
    Senior Coder
    Join Date
    Jul 2003
    Location
    My pimped-out igloo in Canadia
    Posts
    1,966
    Thanks
    36
    Thanked 0 Times in 0 Posts
    I'm sorry Willy.

    There's really nothing else i can say. My example did infact, by my own omission, give you the wrong idea. I infact was the cause of this entire debaucle.

    My 'var url' example was very misleading, it infact did adhere to what you coded and looking back now i'm really sorry. That being said i think you went a little nutso on me.

    Willy, your solution works. I'm sorry that the information i provided you was faulty and i hope that you'll consent to helping me in the future. As for you not suggesting alternatives... that would be a great loss to any project I undertake. I do tend to have tunnel vision and I think that seeing other perspectives is very important. I'm sorry that this episode came about, and i hope that you will continue offering your help, and most of all point of view on situations as the come forth.

    Once again, sorry for my lack of / faulty explanations.
    Sincerely,

    -- Jay
    Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)

  • #13
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Heh Jay;

    It is, in all reality, only a small eArguement and thus insignificant...

    There's really is no need to apologize... And please do not expect an apology from me for going a little nutso, but I'm sorry, I do not apologize to man, woman or beast...

    Perhaps, someday we will meet and as an act of contrition for my behavior, you will allow me the honour of buying you a drink... And thereafter, if you can put this little eArguement aside... We will have many more and agree that the last man standing was right...

    .....Willy

  • #14
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Willy Duitt
    And please do not expect an apology from me for going a little nutso, but I'm sorry, I do not apologize to man, woman or beast...
    What never? That's a pretty tough policy ... must be hard to maintain relationships on that basis.
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #15
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Aye Brothercake, please don't tell me double negatives are lost upon you.... Hopefully, Jay understands what I was trying to say, and if so, that is all that matters (at least to me, all others may embrace their own opinions)....

    Regards;
    .....Willy


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •