Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    New Coder
    Join Date
    Jan 2012
    Thanked 0 Times in 0 Posts

    Passing a form result in a URL parameter

    This is a form to calculate a players age as of May 1st of each year. I need to send the result in a URL string to
    "http://ntsacom.homestead.com/TEST3.html?league_age=[FORM RESULT]
    Can anyone help. This to complete a roster app for our youth league. My javascript is very limited. Thank you!

    <p id="form"></p>
    <form id="get_birthday" name="get_birthday">
    <select id="form_get_month" name="form_birth_month">
    <option value="0">january</option>
    <option value="1">february</option>
    <option value="2">march</option>
    <option value="3">april</option>
    <option value="4">may</option>
    <option value="5">june</option>
    <option value="6">july</option>
    <option value="7">august</option>
    <option value="8">september</option>
    <option value="9">october</option>
    <option value="10">november</option>
    <option value="11">december</option>
    <select id="form_birth_day" name="form_birth_day">
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option>
    <option value="5">5</option>
    <option value="6">6</option>
    <option value="7">7</option>
    <option value="8">8</option>
    <option value="9">9</option>
    <option value="10">10</option>
    <option value="11">11</option>
    <option value="12">12</option>
    <option value="13">13</option>
    <option value="14">14</option>
    <option value="15">15</option>
    <option value="16">16</option>
    <option value="17">17</option>
    <option value="18">18</option>
    <option value="19">19</option>
    <option value="20">20</option>
    <option value="21">21</option>
    <option value="22">22</option>
    <option value="23">23</option>
    <option value="24">24</option>
    <option value="25">25</option>
    <option value="26">26</option>
    <option value="27">27</option>
    <option value="28">28</option>
    <option value="29">29</option>
    <option value="30">30</option>
    <option value="31">31</option>
    <select id="form_get_year" name="form_birth_year">
    <option value="2011">2011</option>
    <option value="2010">2010</option>
    <option value="2009">2009</option>
    <option value="2008">2008</option>
    <option value="2007">2007</option>
    <option value="2006">2006</option>
    <option value="2005">2005</option>
    <option value="2004">2004</option>
    <option value="2003">2003</option>
    <option value="2002">2002</option>
    <option value="2001">2001</option>
    <option value="2000">2000</option>
    <option value="1999">1999</option>
    <option value="1998">1998</option>
    <option value="1997">1997</option>
    <option value="1996">1996</option>
    <option value="1995">1995</option>
    <option value="1994">1994</option>
    <option value="1993">1993</option>
    <input onclick="calculate_age();" type="button" value="submit " />
     <-------------$ I want this to pass as a URL parameter "onclick" of the above button -------------->
    <p id="baseball">
    <script language="JavaScript">
    <!-- hide script from old browsers -->
    function calculate_age()
    var birth_year =  window.document.get_birthday.form_birth_year.value;
    var birth_month = window.document.get_birthday.form_birth_month.value;
    var birth_day = window.document.get_birthday.form_birth_day.value;
    if (((birth_month == 3) || (birth_month ==5) || (birth_month==8) || (birth_month==10)) && (birth_day==31))
    alert("Please check that you entered a valid date")
    if ((birth_month == 1) && (birth_day >28))
    alert("Please check that you entered a valid date")
    //Create the date object for todays date
    var now = new Date();
    //Extract the current  year,
    var the_year = now.getFullYear();
    // Calculate elegibility for sport
    var league_text = ""
    var paragraph = document.getElementById("baseball");
    //Clear the contents of paragraph if the submit button has been clicked more than  once .
    //the Firefox way
    if (paragraph.innerText = "");
    //The MSIE way
    if (paragraph.textContent = "");
    var league_age = (the_year - birth_year)
    if (birth_month > 3)
    league_age --;
    if (league_age < 5 )
    league_text = "1"
    if ((league_age > 5) && (league_age <12))
    league_text = "1"
    else if ((league_age >12) && (league_age <16))
    league_text = "1"
    else if ((league_age >15) && (league_age <19))
    league_text = "1"
    else if (league_age > 18)
    league_text = "1"
    var output_text = document.createTextNode(league_text);
    var output_age = document.createTextNode(league_age);
    Last edited by Baseball; 01-25-2012 at 05:31 PM. Reason: adding [/CODE] tags


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts