Jump to content

javanoob

Members
  • Posts

    31
  • Joined

  • Last visited

Everything posted by javanoob

  1. LMFAO!!! That fixed it. Thank you! I didn't spot that.
  2. That works great, Barand! Thank you so much! I am having an issue with the text in the dropdown selection's text area not showing up though. It seems to be there, but it's not showing up. <select id="menu" name="selection"> <option value="">Choose a Rifle</option> <?php foreach ($data as $row) { echo "<option value={$row['id']} data-em='{$row['em']}' data-gm='{$row['gm']}'>" . htmlspecialchars( $row["rifleName"] ) . "</option>"; } ?> </select> em:<input type="text" class="charge-type" name="em" id="em" value="0" disabled size="5"/> gm: <input class="charge-type" name="gm" id="gm" value="0" disabled size="5"/> The screenshot is without any CSS styling. I tried styling the selection box making the background black and including CSS `color: white;` to try making the text white to see what it did. When I did that the spaces are still there as if the text is there but....it's not there. It's doing as shown in the screenshot in every browser I have except in firefox the background of the text area is black for some reason. Without any CSS styling it. What...um....?? LOL! There's no css: <html> <head> </head> <body> <?php $servername = "localhost"; $dbport = '3306'; I thought FireFox might be doing that because I'm using win10's dark theme. I changed it to default, closed all my windows, re-opened firefox and it's still the same. No text in the menu.
  3. I wasn't aware that was a simulation. You didn't mention that. I'll try this! It's the answer and way of doing if I can manage to get it working! Thank you!
  4. I wasn't aware Barand's suggestion was simulating the database. It wasn't mentioned that it was a simulation. I thought he (she?) was suggesting to write it all out like that. Writing all that out is ouchie.
  5. Your suggestion doesn't access or need a database. It gets it's data from the array in the code file. The script I shared doesn't access the database either. That's what I'd like it to do, what I'm searching and asking for help with: some way of getting the em and gm from the database to display in the input fields without having an excessively long code file. Putting all the data in the code file would be painful task to complete and I'm not sure it would run well. I'm hoping I'm only missing a little snippet of php or jquery/JavaScript I haven't found yet. I spent several years collecting and organizing the data from the game to create the database. News that it can't be done the way I'm trying to do it isn't news I want to hear. I'll accept it if that's the case but it won't be a happy day.
  6. There's something like 30,000 items in 20 or more categories. I'm trying to avoid writing all that out manually (again, I made the database). I'd like the code file to be short and minimal. Is there not a way to make the script I have print the price (in the "em" and "gm" columns) from the database row the selected ID is from into the input fields?
  7. I'm trying to write a budget evaluator web app for a game I play. A sample of the database is as follows: id | rifleName | em | gm | ---------------------------------------------- 1 | .308 Bolt action | 225 | 1350 | 2 | 7mm magnum | 300 | 1575 | 3 | .243 LeverAction | 215 | 8725 | I'm using a dropdown selection menu that's dynamically populated through php and mySQL: <select class='nameItems' id="menu" name="selection"> <option value="">Choose a Rifle</option> <?php foreach ($data as $row): ?> <option value="<?= $row['id'] ?>"><?= htmlspecialchars( $row["rifleName"] ) ?></option> <?php endforeach ?> </select> em:<input type="text" class="charge-type" name="em" value="0" disabled size="5"/> gm: <input class="charge-type" name="gm" value="0" disabled size="5"/> And this script to populate the input fields based on what's selected from the dropdown menu: $("select[name='selection']").change(function() { var selected = $(this).find("option:selected").val(); $("input[name='em']").val(selected); $("select[name='selection']").change(function() { var selected = $(this).find("option:selected").val(); $("input[name='gm']").val(selected); }); }); The script is correctly passing the `id` from the database to the input fields but I want the data from the selected `id` in the `em` and `gm` columns from the database to display in the input fields. I'm struggling to figure out how I would get the script to populate the input fields with the data from the em and gm columns. How would I do that? I'm extremely novice with JavaScript/jQuery is where the issue lies, I think. I've tried this: var selected = $(this).find("option:selected").val('<?= $row['em'] ?>`); in line 2 of the script but it didn't work. I've tried a bunch of different things. I've been at this one thing, for one menu of what's going to be around 20 menu's (different categories of items) for about a month now. I'd really appreciate help getting this to work so I can move forward with the project. Thank you!
×
×
  • 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.