Results 1 to 3 of 3

Thread: drop down box content not diplaying

  1. #1
    Join Date
    Dec 2010

    drop down box content not diplaying

    I'm very new to JavaScript and i'm struggling to get the information selected from the drop down boxes in my form to display in a pop up. The text field and text area information diplays fine. Can anyone tell me why this isnt working?


    <SCRIPT LANGUAGE="JavaScript">
    <!-- Begin
    function displayHTML(form) {
    var inf = form.skill.value;
    var inf2 = form.current.value;
    var inf3 = form.number.value;
    var inf4 = form.years.value;
    var inf5 = form.what.value;
    var inf6 = form.experience.value;
    var inf7 = form.career.value;
    var inf8 = form.target.value;

    win = window.open("", 'popup', 'toolbar = yes, status = no');
    win.document.write("" + "<b>" + "Name: " + "</b>" + inf + "<br>" + "<b>" + "Date: " + "</b>" + inf2 + "<br>" + "<br>" + "<b>" + "The areas you wish to enhance are: " + "</b>" + "<br>" + "<b>" + "1. " + "</b>" + inf3 + "<br>" + "<B>" + "2. " + "</b>" + inf4 + "<br>" + "<b>" + "3. " + "</b>" + inf5 + "<br>" + "<br>" + "<b>" + "The actions you are going to take to enhance these areas are: " + "</b>" + "<br>" + "<b>" + "1. " + "</b>" + inf6 + "&nbsp" + "&nbsp" + "&nbsp" + "&nbsp" + "<b>" + "this will be done by: " +"</b>" + inf7 + "<br>" + "<b>" + "2. " +"</b>" + inf8 + "<br>" + "<br>" + "<br>" + "If you are happy with your Action Plan then click on the button below to print it" + "<html><head><title>popup</title></head><body><br><br>" + "<a href='print.html' onclick='window.print();return false;'>" + "<img src='images/printer.png' height='100px' width='100px'></a></body></html>" + "");
    // End -->

    HTML Form....

    <form id="form1" name="form1" method="post" action="">
    <table width="809" border="1" cellpadding="1" cellspacing="0">
    <td width="799"><h2>Who you are (current position):</h2></td>
    <td><p>I am a
    <label for="number"></label>
    <select name="skill" id="select2">
    <option selected="selected">Please select</option>
    <option>highly skilled</option>
    <option>highly motivated</option>
    <label for="current"></label>
    <input type="text" name="current" id="current" />
    <label for="what"></label>
    <select name="number" id="select3">
    <option>Please select</option>
    years experience in
    <label for="years"></label>
    <input type="text" name="years" id="years" />
    <table width="809" border="1" cellpadding="1" cellspacing="0">
    <td width="799"><h2>What you can do (skills and experience):</h2></td>
    <td><select name="what" id="select">
    <option selected="selected">Please select</option>
    <option>Specific expertise in</option>
    <option>Wide-ranging expertise in</option>
    <option>Responsible for</option>
    <option>Proven ability in</option>
    <label for="experience"></label>
    <textarea name="experience" id="experience" cols="60" rows="2"></textarea>
    <table width="809" border="1" cellpadding="1" cellspacing="0">
    <td width="799"><h2>What you want (career target):</h2></td>
    <td><select name="career" id="career">
    <option selected="selected">Please select</option>
    <option>Looking for a position in</option>
    <option>Seeking an opportunity in</option>
    <option>Seeking to continue a career as</option>
    <option>My objective is to develop a career as</option>
    <textarea name="target" id="target" cols="60" rows="2"></textarea>
    <input type="submit" value="build" onclick="displayHTML(this.form)">

  2. #2
    Join Date
    Dec 2002
    St. Louis, MO, USA
    For SELECT elements, what is natively passed in form submission is not value, but selectedIndex (the zero-index position of the options.) You can get the value, however, by using options[selectedIndex].value.

    var inf = form.skill.options[form.skill.selectedIndex].value;

  3. #3
    Join Date
    Dec 2010
    thank you so much

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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