Results 1 to 3 of 3

Thread: how to check the same value about select menu

  1. #1
    Join Date
    Oct 2007
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default how to check the same value about select menu

    Hi all
    i've a select menu with value from a database, the values are only number, i need to put a control if the user has select the same number, and if yes put an alert, is possilble?

    this is the select menu:

    Code:
    <form method="post" action="galleriaAdmin.asp">
    <select name="posizione_<%=objRSFoto("id_foto")%>" id="posizione_<%=objRSFoto("id_foto")%>" title="seleziona la posizione">
    <%
    for cnt = 1 to maxPosition		
    %>
         <option value="<%=cnt%>"<% if objRSFoto("gl_rank") = cnt then %> selected="selected"<% end if %>><%=cnt%></option>
    <%
    next
    %>
    </select>
    </form>
    thanks for your help
    elisa

  2. #2
    Join Date
    Apr 2010
    Location
    UK
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    You reference the values of currently selected one like this:

    var thevalue = document.FORMNAME.SELECTNAME.options[document.FORMNAME.SELECTNAME.options.selectedIndex].value

    Or so it's easier to read:
    var theselect = document.FORMNAME.SELECTNAME;
    var thevalue = theselect.options[theselect.options.selectedIndex].value;

    Change FORMNAME / SELECTNAME with the name of your form and select tag.

    If you want the value passed to an onchange function etc then you can just use: this.options[this.selectedIndex].value

    Hope that helps!
    Last edited by djr33; 06-18-2010 at 10:49 PM.

  3. #3
    Join Date
    Oct 2007
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by akitodito View Post
    You reference the values of currently selected one like this:

    var thevalue = document.FORMNAME.SELECTNAME.options[document.FORMNAME.SELECTNAME.options.selectedIndex].value

    Or so it's easier to read:
    var theselect = document.FORMNAME.SELECTNAME;
    var thevalue = theselect.options[theselect.options.selectedIndex].value;

    Change FORMNAME / SELECTNAME with the name of your form and select tag.

    If you want the value passed to an onchange function etc then you can just use: this.options[this.selectedIndex].value

    Hope that helps!
    like this:
    Code:
    <script language='javascript' type='text/javascript'>
    var theselect = document.info.posizione;
    var thevalue = theselect.options[theselect.options.selectedIndex].value;
    </script>
    where is the code for alert?

    and the form is now:
    Code:
    <form method="post" action="galleriaAdmin.asp" name="info" id="info">
    <select name="posizione_<%=objRSFoto("id_foto")%>" id="posizione_<%=objRSFoto("id_foto")%>" title="seleziona la posizione">
    <%
    for cnt = 1 to maxPosition		
    %>
         <option value="<%=cnt%>"<% if objRSFoto("gl_rank") = cnt then %> selected="selected"<% end if %> onChange="this.options[this.selectedIndex].value"><%=cnt%></option>
    <%
    next
    %>
    </select>
    </form>
    but is not work , can you help me?
    thanks
    elisa
    Last edited by djr33; 06-18-2010 at 10:50 PM.

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
  •