PHP - Moved: Total Newbie: Simple Url Link, Onclick
This topic has been moved to JavaScript Help.
http://www.phpfreaks.com/forums/index.php?topic=308937.0 Similar TutorialsHello I am very new to php and programming and I need a grand total of "$Total = odbc_result($result, "total");" but not sure of how to create it. Hey all, I've been programming with php for about 3 months now and am still out to lunch on a lot of it. I was hoping someone could help me clear up a problem I'm having with my script. It's a simple script that takes a user selection from the previous page ($StarterPackGroup) and executes a list of randomized functions based on the users selection. (There are 4 races to choose from, here's the url to the page that provides the info for $StarterPackGroup for my script. http://www.eardrumvalley.com/backdoor/MINI_TACTICS/Starter_Pack.php Once the user has selected one of 4 races, it takes them to this php script and rolls for their first "pack". I currently only have the "aqua elves" responding, so click on them. Now, I have the page setup so it generates random numbers, and I know the numbers ARE generating, because I see them with an echo command (you will too, they are at the top of the page). However, the problem I'm having, is trying to utilize these random generated numbers in my other functions. ie: I create $UncommonUnit[$i], $CommonUnit[$i], $RareUnit[$i] and $MonsterUnit in the NewStarterPackRoll function.... however, i can't seem to utilize them in my other functions. How do I pass this info to another function? The echo returns the random numbers from $CommonUnit, $UncommonUnit, $RareUnit and $MonsterUnit just fine WITHIN the StarterPackRoll function, but not later on in the AquaElfStarterPack function. Anytime I try to echo the return value of these holders, I get a blank value... I also know the value isn't being passed between functions because none of my if statements are working either. All the units receive a default allocation (Trooper, Hero, Champion, Skel Sprite), if the randomized numbers were passing, these would be giving me other values as well. Please help, I'm convinced there's a simple answer, and I'm just an idiot when it comes to PHP. Lend me a hand! CODING INFO ----------------- THE DATE ENTREE SCREEN - "http://www.eardrumvalley.com/backdoor/MINI_TACTICS/Starter_Pack.php" (BE SURE TO PICK AQUA ELVES, THEY ARE THE ONLY RACE THAT SENDS VALUES) This will bring you to the script page after you submit the selection: THE SCRIPT CODE ON "Open_First_Pack.php" after the data is sent is as follows: (please browse to webpages to see results of code). <?php function RaceCheck($StarterPackGroup) { if ($StarterPackGroup=="AquaElves") { AquaElfStarterPack(); } } function NewStarterPackRoll() { $i = 0; while ($i < 9) { $i = $i + 1; $CommonUnit[$i] = rand(1, 100); echo "" . $CommonUnit[$i] . " "; } $i = 0; while ($i < 4) { $i = $i + 1; $UncommonUnit[$i] = rand(1, 100); } $i = 0; while ($i < 2) { $i = $i + 1; $RareUnit[$i] = rand(1, 100); } $MonsterUnit = rand(1, 100); } function AquaElfStarterPack() { $i=0; echo "<p><b>Commons:</b><br>"; while ($i < 9) { $i=$i + 1; if ($CommonUnit[$i] <= 20) { $OpenedCommon[$i] = "Trooper"; } else if ($CommonUnit[$i] <= 40) { $OpenedCommon[$i] = "Bowman"; } else if ($CommonUnit[$i] <= 65) { $OpenedCommon[$i] = "Sentinal"; } else if ($CommonUnit[$i] <= 80) { $OpenedCommon[$i] = "Horseman"; } else if ($CommonUnit[$i] <= 100) { $OpenedCommon[$i] = "Evoker"; } echo "" . $CommonUnit[$i] . " "; echo "" . $OpenedCommon[$i] . "<br>"; } echo "</p><p><b>Uncommons:</b><br>"; $i=0; while ($i < 4) { $i=$i + 1; if ($UncommonUnit[$i] <= 20) { $OpenedUncommon[$i] = "Hero"; } else if ($UncommonUnit[$i] <= 40) { $OpenedUncommon[$i] = "Archer"; } else if ($UncommonUnit[$i] <= 65) { $OpenedUncommon[$i] = "Courier"; } else if ($UncommonUnit[$i] <= 85) { $OpenedUncommon[$i] = "Knight"; } else if ($UncommonUnit[$i] <= 100) { $OpenedUncommon[$i] = "Conjurer"; } echo "" . $UncommonUnit[$i] . " "; echo "" . $OpenedUncommon[$i] . "<br>"; } echo "</p><p><b>Rares:</b><br>"; $i=0; while ($i < 2) { $i=$i + 1; if ($RareUnit[$i] <= 15) { $OpenedRare[$i] = "Champion"; } else if ($RareUnit[$i] <= 35) { $OpenedRare[$i] = "Sharp Shooter"; } else if ($RareUnit[$i] <= 55) { $OpenedRare[$i] = "Herald"; } else if ($RareUnit[$i] <= 80) { $OpenedRare[$i] = "Eagle Knight"; } else if ($RareUnit[$i] <= 100) { $OpenedRare[$i] = "Enchanter"; } echo "" . $RareUnit[$i] . " "; echo "" . $OpenedRare[$i] . "<br>"; } echo "</p><p><b>Monster:</b><br>"; if ($MonsterUnit <= 25) { $OpenedMonster = "Skeleton Sprite"; } else if ($MonsterUnit <= 45) { $OpenedMonster = "Tako"; } else if ($MonsterUnit <= 75) { $OpenedMonster = "Coral Giant"; } else if ($MonsterUnit <= 100) { $OpenedMonster = "Gryphon"; } echo "" . $MonsterUnit . " "; echo "" . $OpenedMonster . "</p>"; } NewStarterPackRoll(); RaceCheck($_REQUEST['StarterPackGroup']); ?> This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=330840.0 Hi, I'm new to php and just trying to practice with some codes I have. I have a php code to delete an entry from a database, all works well but I want to try to use the 'onclick' event to prompt for confirmation. However, when I add this I end up with a blank page. Then original code was: echo('<p>' . $commenttext . '<a href="adddelete.php?deletecomment=' . $commentid . '">' . 'Delete this Comment</a></p>'); I changed it to: echo('<p>' . $commenttext . '<a href="adddelete.php?deletecomment=' . $commentid . ' onclick='return confirm('Are you SURE you want to delete this comment?')'">' . 'Delete this Comment</a></p>'); Anyone know what the problem could be, or an alternative way to get a confirmation before deleting? Thanks in advance. Hey there, I just started learning PHP as my first language and after being on different forums for several years I know that you can learn a lot from the knowledge of the communities so I figure may aswell be here on my PHP endeavour. I'm not computer/code illiterate so no need to dumb anything down. My question is about this little script: Code: [Select] <?php foreach($_REQUEST as $value) { echo $value; } ?> I fully understand what it does, I just don't understand how really. What confuses me is how is anything in the $_REQUEST array as I didn't specify/ how does $_REQUEST know what information to pull. Code: [Select] <label for="first_name">First Name:</label> <input type="text" name="first_name" size="20"/><br /> <label for="last_name"><Last Name:</label> <input type="text" name="last_name" size="20"/><br /> <label for="email">Email Address:</label> <input type="text" name="email" size="50"/><br /> Appreciate any explanations for my newbie self. Hello, everyone. I hope what I'm asking for isn't that stupid so I'll give it a shot. In short, I'm an art student who will soon have a minor exam which includes making a simple dynamic website about myself using Dreamweaver - in other words, it's not my field of interest and I'm quite new to this. So, I learned how to use basic HTML and CSS and I've already followed a few tutorials on PHP and databases on Adobe's site but everything is still quite vague and perplexing to me. So what I'm asking for is: would you guys recommend me some simple PHP scripts to include on my website, for which I can find instructions on other websites. Just for the site to be a a bit dynamic. I'm already following a tutorial on how to make a registration/login form, and it's a bit confusing for a newbie like me, but I still try. So, basically, anything that isn't too complex to make. Sorry if that sounded stupid but I don't have anyone else to turn to. I'm constantly reading PHP/database tutorials these days and I am advancing , though really slowly, so I'd really appreciate if someone could give me some advice. Hello all, thanks for everything you do! I used a php from generator to make the form seen on this page: http://www.firstpresgreenville.org/forms/retirementform/retirementform-alt.html I need to be able to click on the check boxes and get a dollar amount total in the total field....So if you checked "single", the total field would read $40, and if you checked on "couple", the field would read $50...simple as that... Is there anyway to make that happen? This is the code I am working with now.... <?php # This block must be placed at the very top of page. # -------------------------------------------------- require_once( dirname(__FILE__).'/form.lib.php' ); phpfmg_display_form(); # -------------------------------------------------- function phpfmg_form( $sErr = false ){ $style=" class='form_text' "; ?> <form name="frmFormMail" action='' method='post' enctype='multipart/form-data' onsubmit='return fmgHandler.onsubmit();'> <input type='hidden' name='formmail_submit' value='Y'> <div id='err_required' class="form_error" style='display:none;'> <label class='form_error_title'>Please check the required fields</label> </div> <ol class='phpfmg_form' > <li class='field_block' id='field_0_div'><div class='col_label'> <label class='form_field'>Full Name(s)</label> <label class='form_required' >*</label> </div> <div class='col_field'> <input type="text" name="field_0" id="field_0" value="<?php phpfmg_hsc("field_0"); ?>" class='text_box'> <div id='field_0_tip' class='instruction'></div> </div> </li> <li class='field_block' id='field_1_div'><div class='col_label'> <label class='form_field'>Street Address</label> <label class='form_required' >*</label> </div> <div class='col_field'> <input type="text" name="field_1" id="field_1" value="<?php phpfmg_hsc("field_1"); ?>" class='text_box'> <div id='field_1_tip' class='instruction'></div> </div> </li> <li class='field_block' id='field_2_div'><div class='col_label'> <label class='form_field'>City</label> <label class='form_required' >*</label> </div> <div class='col_field'> <input type="text" name="field_2" id="field_2" value="<?php phpfmg_hsc("field_2"); ?>" class='text_box'> <div id='field_2_tip' class='instruction'></div> </div> </li> <li class='field_block' id='field_3_div'><div class='col_label'> <label class='form_field'>State</label> <label class='form_required' >*</label> </div> <div class='col_field'> <input type="text" name="field_3" id="field_3" value="<?php phpfmg_hsc("field_3"); ?>" class='text_box'> <div id='field_3_tip' class='instruction'></div> </div> </li> <li class='field_block' id='field_4_div'><div class='col_label'> <label class='form_field'>Zip Code</label> <label class='form_required' >*</label> </div> <div class='col_field'> <input type="text" name="field_4" id="field_4" value="<?php phpfmg_hsc("field_4"); ?>" class='text_box'> <div id='field_4_tip' class='instruction'></div> </div> </li> <li class='field_block' id='field_5_div'><div class='col_label'> <label class='form_field'>Phone</label> <label class='form_required' >*</label> </div> <div class='col_field'> <input type="text" name="field_5" id="field_5" value="<?php phpfmg_hsc("field_5"); ?>" class='text_box'> <div id='field_5_tip' class='instruction'>(###) ###-####</div> </div> </li> <li class='field_block' id='field_6_div'><div class='col_label'> <label class='form_field'>Email</label> <label class='form_required' >*</label> </div> <div class='col_field'> <input type="text" name="field_6" id="field_6" value="<?php phpfmg_hsc("field_6"); ?>" class='text_box'> <div id='field_6_tip' class='instruction'></div> </div> </li> <li class='field_block' id='field_7_div'><div class='col_label'> <label class='form_field'>Number of Attendees</label> <label class='form_required' >*</label> </div> <div class='col_field'> <input type="text" name="field_7" id="field_7" value="<?php phpfmg_hsc("field_7"); ?>" class='text_box'> <div id='field_7_tip' class='instruction'></div> </div> </li> <li class='field_block' id='field_8_div'><div class='col_label'> <label class='form_field'>Single or Couple?</label> <label class='form_required' >*</label> </div> <div class='col_field'> <?php phpfmg_checkboxes( 'field_8', "Single|Couple" );?> <div id='field_8_tip' class='instruction'></div> </div> </li> <li class='field_block' id='field_9_div'><div class='col_label'> <label class='form_field'>Amount Due</label> <label class='form_required' >*</label> </div> <div class='col_field'> <input type="text" name="field_9" id="field_9" value="<?php phpfmg_hsc("field_9"); ?>" class='text_box'> <div id='field_9_tip' class='instruction'>$40/ single or $50/couple (Includes one book and lunch)</div> </div> </li> <li class='field_block' id='field_10_div'><div class='col_label'> <label class='form_field'>Additional Comments</label> <label class='form_required' > </label> </div> <div class='col_field'> <textarea name="field_10" id="field_10" rows=4 cols=25 class='text_area'><?php phpfmg_hsc("field_10"); ?></textarea> <div id='field_10_tip' class='instruction'></div> </div> </li> <?php phpfmg_dependent_dropdown( 'field_11' );?> <li> <div class='col_label'> </div> <div class='form_submit_block col_field'> <input type='submit' value='Submit' class='form_button'> <span id='phpfmg_processing' style='display:none;'> <img id='phpfmg_processing_gif' src='<?php echo PHPFMG_ADMIN_URL . '?mod=image&func=processing' ;?>' border=0 alt='Processing...'> <label id='phpfmg_processing_dots'></label> </span> </div> </li> </ol> </form> <?php phpfmg_javascript($sErr); } # end of form function phpfmg_form_css(){ ?> Thanks so much! <html> <head> <title>Sum Html Textbox Values using jQuery/JavaScript</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <script> $(function() { $(document).on('blur keyup', '.add, .sub', function(e) { var sum = 0; $('.add, .sub').each(function(i) { if (!isNaN(this.value) && this.value.length != 0) { if ($(this).hasClass('add')) { sum += parseFloat(this.value); } else { sum -= parseFloat(this.value); } } }); $('#total').text(sum.toFixed(2)); }) }) </script> </head> <body> <form method="post" action="calc.php"> Addition: <br/> Field 1: <input type="text" class="add" name="1" value="7500"/><br/> Field 2: <input type="text" class="add" name="2" value=""/><br/> Field 3: <input type="text" class="add" name="3" value=""/><br/> Field 4: <input type="text" class="add" name="4" value=""/><br/><br/> Total Addition: <br/><br/> Substraction: <br/> Field 1: <input type="text" class="sub" name="5" value=""/><br/> Field 2: <input type="text" class="sub" name="6" value=""/><br/> Field 3: <input type="text" class="sub" name="7" value=""/><br/> Field 4: <input type="text" class="sub" name="8" value=""/><br/><br/> Total Substraction: <br/><br/> Grand Total: <div id="total"></div> <input type="submit" value="submit" /> </form> </body> </html> This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=342707.0 This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=308673.0 This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=358574.0 Amazingly, PHP Coding Help is not the place to ask JavaScript questions. Mind blown. This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=332796.0 Amazingly, PHP Coding Help != JavaScript Help. This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=333336.0 This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=333337.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=343169.0 This topic has been moved to Other Libraries and Frameworks. http://www.phpfreaks.com/forums/index.php?topic=321319.0 This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=359130.0 Hi, This is a image tooltip from database. but I have got the problem, Not Working! How can i fix it. <a href="index.php?MD=urundetay&resimid=<?php echo $row_uruns['resimid']; ?>"><img src="urun_resim/<?php echo $row_image['image']; ?>" width="150" border="0" /></a> This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=349116.0 This topic has been moved to PHP Math Help. http://www.phpfreaks.com/forums/index.php?topic=357542.0 |