By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,256 Members | 1,663 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,256 IT Pros & Developers. It's quick & easy.

Output Form Dropdown to HTML Page

P: 7
Hello,

For a roleplaying fansite I am trying to give visitors a convenient way to make people add items to their game. They need to enter hexcodes for items and I'd like to help with the task.

What i have now is a list that is basically like this:

Expand|Select|Wrap|Line Numbers
  1. <h2>Create Item Links</h2>
  2. <form name="frmSelect">
  3. <select id="Location" name="Location">
  4. <option value="player.placeatme">Place at Player</option>
  5. <option value="player.additem">Place in Inventory</option>
  6. </select>
  7. <select id="Item-ID" name="Item-ID">
  8. <option value="43e1e">Alessandra's Dagger</option>
  9. <option value="79b1d">Blade of Sacrifice</option>
  10. </select>
  11. <select id="Amount" name="Amount">
  12. <option value="1">1</option>
  13. <option value="2">2</option>
  14. </select>
  15. </form>
  16. Use this code in Skyrim's Console to receive the Item:
  17.  
  18. player.additem 431e1 1
  19.  
Selecting the first options should give the bolded output. What I have so far is:

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. function get_skcommand()
  3. {
  4. var skcommand = document.getElementById('location').value + document.getElementById('itemid').value + document.getElementById('amount').value;
  5. }
  6. </script>
  7.  
How can I get the skcommand output to a page and dynamically update it if I change selections?

Thanks in advance.

Michael
Nov 17 '11 #1

✓ answered by Dormilich

there are several methods to output a value:
- into a form field:
Expand|Select|Wrap|Line Numbers
  1. <input type="text" id="display" size="7" readonly>
  2.  
  3. // change value
  4. document.getElementById("display").value = "something to display";
- into an other element
Expand|Select|Wrap|Line Numbers
  1. <p id="display"></p>
  2.  
  3. // change value
  4. document.getElementById("display").innerHTML = "something to display";
to update the value you just need to call the calculating/outputting function when this event (e.g. the change event) on one of the selection occurs.

Expand|Select|Wrap|Line Numbers
  1. // using event listeners
  2. function helpUser(evt)
  3. {
  4.     // calculate value 
  5.     // output value 
  6. }
  7. // select being the <select> element (define beforehand)
  8. // repeat for every select element 
  9. // works in all browsers except IE < 9
  10. select.addEventListener("change", helpUser, true);

Share this Question
Share on Google+
2 Replies


Dormilich
Expert Mod 5K+
P: 8,639
there are several methods to output a value:
- into a form field:
Expand|Select|Wrap|Line Numbers
  1. <input type="text" id="display" size="7" readonly>
  2.  
  3. // change value
  4. document.getElementById("display").value = "something to display";
- into an other element
Expand|Select|Wrap|Line Numbers
  1. <p id="display"></p>
  2.  
  3. // change value
  4. document.getElementById("display").innerHTML = "something to display";
to update the value you just need to call the calculating/outputting function when this event (e.g. the change event) on one of the selection occurs.

Expand|Select|Wrap|Line Numbers
  1. // using event listeners
  2. function helpUser(evt)
  3. {
  4.     // calculate value 
  5.     // output value 
  6. }
  7. // select being the <select> element (define beforehand)
  8. // repeat for every select element 
  9. // works in all browsers except IE < 9
  10. select.addEventListener("change", helpUser, true);
Nov 17 '11 #2

P: 7
Thanks a lot, I went for solution 2 and it worked!

Expand|Select|Wrap|Line Numbers
  1. <select id="location" name="location" onchange='get_skcommand();'>
and by adding

Expand|Select|Wrap|Line Numbers
  1. document.getElementById("display").innerHTML = "something to display";
  2.  
to the script above.

You will be able to see the script in action here:

http://skyrim.mmo-game.eu/skyrim-item-link-creator/

Thanks!
Nov 17 '11 #3

Post your reply

Sign in to post your reply or Sign up for a free account.