Jump to content

glennn.php

Newly Registered
  • Posts

    251
  • Joined

  • Last visited

Everything posted by glennn.php

  1. awesome, Premiso, and i thank you, but it's a (simple mathematic) javascript function i'm calling: function mult() { // Get values from form mo = document.getElementById('monthly...').value; oft = document.getElementById('often...').value; var product = mo*oft; document.getElementById('net...').value = product; } where i don't know how to get the three form field variables passed ... <input id= "monthly1", "monthly2", etc... <input id= "often1", "often2", etc... <input id= "net1", "net2", etc...
  2. so i'm still going to have to define these 10 vars in each of these 10 functions anyway, which is what i was trying to avoid... then isn't there a way to make this function more generic in order to do the same thing for 10 different forms, like function mult() { // Get values from form mo = document.getElementById('monthly...').value; oft = document.getElementById('often...').value; var product = mo*oft; document.getElementById('net...').value = product; where there are a series of form fields, id="monthly1", id="monthly2", etc...? where the function is called from a form select onchange event...? maybe not...? thanks much, MrAdam
  3. well, the function works great with them inside it - i'm not a javascript coder whatsoever. i work in php. in other words, what's firebug? )
  4. that's what i read, using "var" and NOT using "var", only neither worked...
  5. i don't know how to make certain vars global, or at least available to several functions: function mult1() { // Get values from form mo = document.getElementById('monthly1').value; oft = document.getElementById('often1').value; // Compute the product. var product = mo*oft; // Display product in form. // document.wizForm.sc1_net.value = product; document.getElementById('net1').value = product; n1 = document.getElementById('net1').value; n2 = document.getElementById('net2').value; n3 = document.getElementById('net3').value; n4 = document.getElementById('net4').value; n5 = document.getElementById('net5').value; n6 = document.getElementById('net6').value; n7 = document.getElementById('net7').value; n8 = document.getElementById('net8').value; n9 = document.getElementById('net9').value; n10 = document.getElementById('net10').value; tot = parseInt(n1) + parseInt(n2) + parseInt(n3) + parseInt(n4) + parseInt(n5) + parseInt(n6) + parseInt(n7) + parseInt(n8) + parseInt(n9) + parseInt(n10); document.getElementById('total').value = tot; } i'd like to make n1 through n10 available to 10 functions just like this one, but i've not been able to. i've tried what i've found online, but to no avail. i'd REALLY like to make this function work for ten different forms, and requested help in another string, but have received no replies... thanks for your help, in either manner ) GN
  6. i'd like to make this function - mult1() - work on several similar forms like the ones below: function mult1() { // Get values from form var monthly,often; mo = document.getElementById('monthly').value; oft = document.getElementById('often').value; // Compute the product. var product = mo*oft; // Display product in form. // document.wizForm.sc1_net.value = product; document.getElementById('net').value = product; } <div class="row"> <div class="row1">Source 1</div> <div class="row2"><input type="text" name="sc1_mo" id="monthly1" /></div> <div class="row3"> <select name="sc1_oft" id="often1" onChange="mult1()"> <option name="" value="4">Weekly</option> <option name="" value="2">Every 2 Weeks</option> <option name="" value="2">Bi-Monthly</option> <option name="" value="1">Monthly</option> </select> </div> <div class="row4"> <input name="sc1_net" id="net1" type="text" readonly /> </div> </div> <div class="row"> <div class="row1">Source 1</div> <div class="row2"><input type="text" name="sc2_mo" id="monthly2" /></div> <div class="row3"> <select name="sc2_oft" id="often2" onChange="mult1()"> <option name="" value="4">Weekly</option> <option name="" value="2">Every 2 Weeks</option> <option name="" value="2">Bi-Monthly</option> <option name="" value="1">Monthly</option> </select> </div> <div class="row4"> <input name="sc2_net" id="net2" type="text" readonly /> </div> </div> not too good with javascript, i appreciate any help... thanks again, GN
  7. very true. i'm not good at JOINS and multiple tables, especially when the client wants to pay budget scale... be that as it is, can you show me how i'd get Acura out of that array? i am in fact researching how i'd normalize this table - i hate to do a bad job even when the money isn't right. i'm much obliged...
  8. i have a field, "models", which will contain an array such as "Acura, Camaro, Blazer" - i'm trying to learn how to use IN to get any row that would contain "Acura" within that field. SELECT * from TABLE WHERE 'Acura' IN 'models'...? that didn't work... anyone...? thanks much GN
  9. that's exactly what i thought, too. thanks, that was very helpful. i did, in fact, merge a couple of tables and this made everything much easier (and more logical)... thanks again
  10. so then maybe there's a better way to layout that database... thanks much
  11. i'd love some help with a complex (for me) db layout for each registered client, i have 17 forms - Categories, each with as many as 24 values - Items, to be stored. i was advised to create a Cats table, with cat_id and cat_name, and an items table, with cat_id, item_id, and item_name, and an amounts table, with client_id, cat_id, item_id, amount ... but this seems a bit obtuse. could someone tell me if there's a simpler way to store such data? i've become a bit confused now... ) thanks much GN
  12. i've been given a table designed thusly: clients_b: id client_id item_id amount notes; which stores MANY values (amount, notes) per client... having a form with the fields 'rent', 'elec', 'gas', 'water', and 20 more, the best query i can come up with is $query = "UPDATE client_budgets SET amount = '$rent_amt', notes = '$rent_notes' WHERE client_id = '$cid' AND item_id = '13'"; $query = "UPDATE client_budgets SET amount = '$elec_amt', notes = '$elec_notes' WHERE client_id = '$cid' AND item_id = '14'"; $query = "UPDATE client_budgets SET amount = '$gas_amt', notes = '$gas_notes' WHERE client_id = '$cid' AND item_id = '15'"; but i don't want to do that 24 times for each form - i'm hoping someone will help me get these values into an array that can be inserted (or updated) into this table... or IS IT ok to run 24 queries like that on a submit...? sure doesn't seem to be... thanks much! GN
  13. beautiful. works like a champ. thanks, mr adam...
  14. no, there are 17 different forms i'd use this on, with a varying number of assigned items. one form has 24 values...
  15. i have some form fields such as "rent", "elec", "gas", etc... where the values for these fields are stored in a db table with an item_id assigned to each item... using this: while ($row = mysql_fetch_array($result)) { echo $row['item_id'].": ".$row['amount']; } i'm not sure how to get the amounts for item_ids 13, 14, 15... into an array so that i can echo them elsewhere (in their respective textfields), 13 being "rent", 14 being "elec", etc... thanks for the help GN
  16. awesome, can't wait to look this over - you'll see the ENTIRE form here, just in case you're curious: www.glennnall.com/perimeterresearch thanks again for your time and trouble... GN
  17. very grateful, thanks part of the form: <div class="oneField"> <label class="preField">Do you drink alcohol?</label> <span class="oneChoice"> <input type="checkbox" value="No" name="drink[]"> <label for="No" class="postField">No</label> </span> <span class="oneChoice"> <input type="checkbox" value="Beer" id="beer" name="drink[]"> <label for="Beer" class="postField">Beer</label> </span> <span class="oneChoice"> <input type="checkbox" value="Wine" id="wine" name="drink[]"> <label for="Beer" class="postField">Wine</label> </span> <span class="oneChoice"> <input type="checkbox" value="Liquor" id="liquor" name="drink[]"> <label for="Beer" class="postField">Liquor</label> </span> </div> <div style="float:left; width:220px;"> <input type="checkbox" name="beer[]" value="Miller Lite"> Miller Lite<br /> <input type="checkbox" name="beer[]" value="Modelo"> Modelo<br /> <input type="checkbox" name="beer[]" value="Molson"> Molson<br /> <input type="checkbox" name="beer[]" value="Natural Lite"> Natural Lite<br /> <input type="checkbox" name="beer[]" value="Pabst Blue Ribbon"> Pabst Blue Ribbon<br /> <input type="checkbox" name="beer[]" value="Rolling Rock"> Rolling Rock<br /> <input type="checkbox" name="beer[]" value="Sam Adams"> Sam Adams<br /> <input type="checkbox" name="beer[]" value="St. Pauli Girl"> St. Pauli Girl<br /> <input type="checkbox" name="beer[]" value="Tecate"> Tecate<br /> <input type="checkbox" name="beer[]" value="Yuengling"> Yuengling<br /> </div> <div style="clear:left; padding-left:5px; margin-bottom:10px;"> Other <input id="ber" name="beer[]" /> </div> // AND WINE AND LIQUOR... just trying to validate that at least one BEER option has a value IF "drink[], beer" is checked, and wine and liquor... thanks for your help very much, GN
  18. i know VERY little of js - but i'm SURE this could be consolidated (it works fine, it's just a little obtuse, i think): var dr=new Array(); dr=document.getElementsByName("drink[]"); var dri=-1; for(i=0;i<dr.length;i++){ if(dr[0].checked){ dri=0; } if(dr[1].checked){ dri=1; } if(dr[2].checked){ dri=2; } if(dr[3].checked){ dri=3; } if((dr[1].checked) && (dr[2].checked)){ dri=4; } if((dr[1].checked) && (dr[3].checked)){ dri=5; } if((dr[2].checked) && (dr[3].checked)){ dri=6; } if((dr[1].checked) && (dr[2].checked) && (dr[3].checked)){ dri=7; } } if (dri == -1){ alert('please indicate whether or not you drink alcohol'); return false; } var br=new Array(); br=document.getElementsByName("beer[]"); var beer=0; for(i=0;i<br.length;i++){ if(br[i].checked){ beer=1; } } var wn=new Array(); wn=document.getElementsByName("wine[]"); var wine=0; for(i=0;i<wn.length;i++){ if(wn[i].checked){ wine=1; } } var li=new Array(); li=document.getElementsByName("liquor[]"); var liq=0; for(i=0;i<li.length;i++){ if(li[i].checked){ liq=1; } } if ((dri == 1) && (beer == 0)) { alert('beer'); return false; } if ((dri == 2) && (wine == 0)) { alert('wine'); return false; } if ((dri == 3) && (liq == 0)) { alert('liquor'); return false; } if ((dri == 4) && (beer == 0) && (wine == 0)) { alert('beer and wine'); return false; } if ((dri == 4) && (beer == 0) && (wine == 1)) { alert('beer'); return false; } if ((dri == 4) && (beer == 1) && (wine == 0)) { alert('wine'); return false; } if ((dri == 5) && (beer == 0) && (liq == 0)) { alert('beer and liquor'); return false; } if ((dri == 5) && (beer == 0) && (liq == 1)) { alert('beer'); return false; } if ((dri == 5) && (beer == 1) && (liq == 0)) { alert('liquor'); return false; } if ((dri == 6) && (wine == 0) && (liquor == 0)) { alert('wine and liquor'); return false; } if ((dri == 6) && (wine == 0) && (liquor == 1)) { alert('wine'); return false; } if ((dri == 6) && (wine == 1) && (liquor == 0)) { alert('liquor'); return false; } if ((dri == 7) && (beer == 0) && (wine == 0) && (liq == 0)) { alert('beer and wine and liquor'); return false; } if ((dri == 7) && (beer == 0) && (wine == 0) && (liq == 1)) { alert('beer and wine'); return false; } if ((dri == 7) && (beer == 0) && (wine == 1) && (liq == 0)) { alert('beer and liquor'); return false; } if ((dri == 7) && (beer == 0) && (wine == 1) && (liq == 1)) { alert('beer'); return false; } if ((dri == 7) && (beer == 1) && (wine == 0) && (liq == 0)) { alert('wine and liquor'); return false; } if ((dri == 7) && (beer == 1) && (wine == 0) && (liq == 1)) { alert('wine'); return false; } if ((dri == 7) && (beer == 1) && (wine == 1) && (liq == 0)) { alert('liquor'); return false; } can someone kindly show me how this might be shortened...? i'm grateful - GN
  19. ok, i appreciate it - but what i don't get is that the data is WITHOUT the quotes IN Excel - it happens during the import INTO the database - so how is it that Excel is causing it? even after the .csv import, the data in the .csv file is fine (WITHOUT the quotes). only the data in mysql is affected... when you say "clean it up with regexp", you mean to clean the mysql data with regexp???
  20. $if ($o_1 == "option_19001") { $pagetext .= "aaa'; } elseif ($o_1 == "option_19002") { // $option_19001 thru $option_19176 $pagetext .= "bbb"; etc... } if ($o_2 == "option_19001") { $pagetext .= "aaa'; } elseif ($o_2 == "option_19002") { // $option_19001 thru $option_19176 $pagetext .= "bbb"; etc... } // $o_1 thru $o_76 echo $pagetext;
  21. MS Excel. it's not being done in MS Excel - they're correct in the spreadsheet. only after the data is imported into mysql are the quotes added...
  22. i'm very sorry. i don't know why this is hard to understand... i have 76 variables i retrieve from the database: $o_1 = $row['option_1']; $o_76 = $row['option_76']; each variable in turn contains 1 of 175 values each of which refer to another (longer) value. my client did this in a spreadsheet. option_19001 thru option_19176 so for each $o_xx (x 76) I have "option_xxxxx" which represents a value contained in a long switch... am i being daft?
  23. heck, i'll write it in english/sql... select * from table where id = 1; i'll get o _1 thru o_76 THAT CONTAIN A VALUE if ($o_1 == "option_19001") { pagetext .= "aaa'; } elseif ($o_1 == "option_19002") { // $option_19001 thru $option_19176 pagetext .= "bbb"; } if ($o_2 == "option_19001") { pagetext .= "aaa'; } elseif ($o_2 == "option_19002") { // $option_19001 thru $option_19176 pagetext .= "bbb"; } // $o_1 thru $o_76
×
×
  • 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.