SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Oct 2002
    Location
    Madison, WI
    Posts
    198
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    validating select box troubles

    Hi,

    Here's my code:

    Code:
    <script language="javascript">
    function confirmEndSession() {
    if(window.document.EndSession.Area.value='x') {
    alert('You must select an area of counseling.\nYou may have mistakenly selected a header\ninstead of an area.'); }
    else { window.document.EndSession.submit() }
    }
    </script>
    <form name="EndSession" method="post">
    <select name="Area">
    <option value="x">Technology</option> 
    <option value="1306" style="font-size:80%;">&nbsp;&nbsp;&middot;Copyright</option>
    <option value="1302" style="font-size:80%;">&nbsp;&nbsp;&middot;Disclosure Document</option>
    <option value="1312" style="font-size:80%;">&nbsp;&nbsp;&middot;E-Commerce</option>
    </select>
    <input type="button" value="End Session" class="btn" onclick="confirmEndSession();" />
    </form>
    I am trying to prevent the user from selecting the first option, with value 'x'. When the script runs, however, I get the alert no matter what is selected, and the select jumps back to the first option (Technology).

    Please advise, thanks.
    :::::::::::::::::::::::::::::::::::::::::::::::::::
    Versa Studio
    ExpressionEngine experts
    bas (at) versa studio dot com

  2. #2
    ********* Ornithologist AtomicPenguin's Avatar
    Join Date
    May 2002
    Location
    Vancouver, BC
    Posts
    459
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is the age old '=' vs '==' problem. I do it all the time. :-)

    Just change:

    HTML Code:
     if(window.document.EndSession.Area.value='x') {
    to:

    HTML Code:
    if(window.document.EndSession.Area.value=='x') {

  3. #3
    SitePoint Zealot
    Join Date
    Oct 2002
    Location
    Madison, WI
    Posts
    198
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    got it, thanks!
    :::::::::::::::::::::::::::::::::::::::::::::::::::
    Versa Studio
    ExpressionEngine experts
    bas (at) versa studio dot com


Bookmarks

Posting Permissions

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