Jump to content

D&D character maker help


Punchin
 Share

Recommended Posts

A friend of mine is trying to make a pretty much all-inclusive D&D character creater local web page. He'd like it dynamic so you can load/save characters, but that's beyond both of our scopes right now. What I'm trying to do is figure out and refine how to create a new page based on options selected form a drop down box.Here's my current code:

<HTML><HEAD><script TYPE="text/javascript">function CharCreate(){var Name=prompt("Name Your Character","")var race=document.getElementById("Race")var race=race.options[race.selectedIndex].textvar class=document.getElementById("Class")var class=class.options[class.selectedIndex].textdocument.write(<FONT SIZE=10><B><CENTER> + "Dungeons and Dragons Character Creator" + "<BR></CENTER></B></FONT><BR> + "Name:" + name + "<BR>Race: " + race + "<BR>Class: " + class)}</SCRIPT></HEAD><BODY><FORM><SELECT ID="Race"><OPTION SELECTED>~~~RACE~~~<OPTION>Human<OPTION>Elf<OPTION>Half-Elf<OPTION>Orc<OPTION>Halfling</SELECT><SELECT ID="Class"><OPTION SELECTED>~~~CLASS~~~<OPTION>Fighter<OPTION>Monk<OPTION>Sorceror<OPTION>Wizard<OPTION>Rogue<OPTION>Cleric<OPTION>Druid</SELECTED><BR><INPUT TYPE="button" VALUE="Make Character" onClick="CharCreate()">

When I click the button nothing happens. Also, what command would I use to make it open and create a new page instead of trying to overwrite the current page?

Link to comment
Share on other sites

1st problem - class is a reserved keyword so you cannot use it to define a variblevar class=document.getElementById("Class") :) var status=document.getElementById("status") :) 2nd problem - the quotes in document.write was all messed up so i changed it

Also, what command would I use to make it open and create a new page instead of trying to overwrite the current page?
See the bit in Red<HTML><HEAD><script TYPE="text/javascript">function CharCreate(){var Name=prompt("Name Your Character","");var race=document.getElementById("Race");race=race.options[race.selectedIndex].text;var status=document.getElementById("status")status=status.options[status.selectedIndex].text;var str="<FONT SIZE=10><B><CENTER>Dungeons and Dragons Character Creator<BR></CENTER></B></FONT><BR>Name: " + Name + "<BR>Race: " + race + "<BR>Class: " + status;var winPtr = window.open('', '_blank', '');winPtr.document.open();winPtr.document.writeln(str);winPtr.document.close();}</SCRIPT></HEAD><BODY><FORM><SELECT ID="Race"><OPTION SELECTED>~~~RACE~~~<OPTION>Human<OPTION>Elf<OPTION>Half-Elf<OPTION>Orc<OPTION>Halfling</SELECT><SELECT ID="status"><OPTION SELECTED>~~~CLASS~~~<OPTION>Fighter<OPTION>Monk<OPTION>Sorceror<OPTION>Wizard<OPTION>Rogue<OPTION>Cleric<OPTION>Druid</SELECTED><BR><INPUT TYPE="button" VALUE="Make Character" onClick="CharCreate()">Are you using html 4 or something :) i'll leave that for you to sort out.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...