Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Regular Coder
    Join Date
    Feb 2006
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts

    combo box!!!!!!!!!!

    Why everytime i refresh the page....what i selected in the combo box will also refresh(disappear)....but for text box, i write like this...the text box that user enter...can maintain inside the text box...urgent!!!!help me pls...

    Code:
    <select name="txtDate2" id="dates" <%if haha<>"cancel" then%>value="<%=request("txtDate2")%>"<%else%>value=""<%end if%>>
    <option value="0">---</option>
    <option value="1">01</option>
    <option value="2">02</option>
    <option value="3">03</option>
    <option value="4">04</option>
    <option value="5">05</option>
    <option value="6">06</option>
    <option value="7">07</option>
    <option value="8">08</option>
    <option value="9">09</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>

  • #2
    New Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    35
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If you REFRESH the page, the page and all the content in it will be refreshed, meaning everything you have entered without saving will disappear.

  • #3
    Regular Coder
    Join Date
    Feb 2006
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts
    but the text box below...the content still appear when i refresh the page....can sombody tell me why please????

    [code]
    <td colspan=5><input type="text" name="amount" onkeypress="return isNumberKey(event)" value="<%if haha<>"cancel" then%><%=server.HTMLEncode(request("amount"))%><%end if%>"><% if subop6="erroramount" then %><span class="red">*</span><% end if %></td>
    </tr>
    [/cede]

  • #4
    New Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    35
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Because the value of the text field is dependant on the value of the variable 'haha'. So when you refresh the page, if the variable haha does not equal cancel, then the value of the text field will have something in it.

    Apply the same principle to the values in the dropdown, eg.

    <option value="0" <%=If yourVariable="0" Then Response.Write "selected"%>>---</option>

  • #5
    Regular Coder
    Join Date
    Feb 2006
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts
    so is it using ur way....the value inside the combo box that is choose by the user will always appear even thought i refresh it???


  • #6
    New Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    35
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If you refresh the page and there is no data that can be used to base other elements on the form on, then they will be refreshed and await the user to enter/select them.

    If you have server side data that can be used to select the appropriate value on the combo box, when you refresh it, it will use this data to reselect the value in the dropdown.

  • #7
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If you are wanting to show the selected option then here is an example

    Code:
    <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    </head>
    
    <body>
    <form name="form1" method="post" action="">
      <select name="mySelectBox">
      <%For x=1 to 20%>
      	<option value="<%=x%>"<%If Cstr(x)=Cstr(Request.Form("mySelectBox")) Then Response.Write " selected"%>>Option: <%=x%></option>
      <%Next%>
      </select>
      <input type="submit" name="Submit" value="Submit">
    </form>
    <p>
    <%
    If Request.Form("mySelectBox") > 0 Then
    	Response.Write "you chose option: " & Request.Form("mySelectBox")
    End If
    %>
    </p>
    </body>
    </html>

  • #8
    Regular Coder
    Join Date
    Feb 2006
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes....That's what i want...you are great....Thank you very much....

    Another problem again....You did for me is DAY....How about my month follow with year?????????thanks

    Code:
    <script type="text/javascript">
    function addMonths() {
           var MONTHS=["Jan", "Feb", "Mar ", "Apr ", "May ", "Jun ", "Jul ", "Aug ", "Sep ", "Oct ", "Nov ", "Dec "];
           var today=new Date();
           var thisYear=today.getFullYear();
           var thisMonth=today.getMonth();
           for (var x=0; x<=thisMonth; x++) { // Use this if you want January to be first
           //for (var x=thisMonth; x>=0; x--) { // Use this if you want the current month to be first
                   var option = document.createElement('option');
                   option.value=thisMonth+1;
                   var text = document.createTextNode(MONTHS[x]+'-'+thisYear);
                   option.appendChild(text);
                   document.getElementById('months').appendChild(option);
           }
    }
    </script>
    
    <select name="txtDate1" id="months">
    <option>---</option>
    </select>
    <% if subop8="errordate" then%><span class="red">*</span><% end if %>
    What should i write?????

  • #9
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'm not sure what you mean. What are you trying to achieve?

  • #10
    Regular Coder
    Join Date
    Feb 2006
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i've tried to use the same method in second combo box(months follow with year)like yours...but the the 2nd combo box still disapper againafter i click submit button(like the first problem on top)...why??

    how should i fix it??

    thanks

  • #11
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Another problem again....You did for me is DAY....How about my month follow with year?????????thanks
    i've tried to use the same method in second combo box(months follow with year)like yours
    Sorry, but I do not know what you mean.

  • #12
    Regular Coder
    Join Date
    Feb 2006
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts
    sorry....

    i mean how can i use this method apply inside my code??

    Code:
    <option value="<%=x%>"<%If Cstr(x)=Cstr(Request.Form("mySelectBox")) Then Response.Write
    my code:

    Code:
    <script type="text/javascript">
    function addMonths() {
           var MONTHS=["Jan", "Feb", "Mar ", "Apr ", "May ", "Jun ", "Jul ", "Aug ", "Sep ", "Oct ", "Nov ", "Dec "];
           var today=new Date();
           var thisYear=today.getFullYear();
           var thisMonth=today.getMonth();
           for (var x=0; x<=thisMonth; x++) { // Use this if you want January to be first
           //for (var x=thisMonth; x>=0; x--) { // Use this if you want the current month to be first
                   var option = document.createElement('option');
                   option.value=thisMonth+1;
                   var text = document.createTextNode(MONTHS[x]+'-'+thisYear);
                   option.appendChild(text);
                   document.getElementById('months').appendChild(option);
           }
    }
    </script>
    
    <select name="txtDate1" id="months">
    <option>---</option>
    </select>
    thank you

  • #13
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Code:
    function addMonths() {
           var MONTHS=["Jan", "Feb", "Mar ", "Apr ", "May ", "Jun ", "Jul ", "Aug ", "Sep ", "Oct ", "Nov ", "Dec "];
           var today=new Date();
           var thisYear=today.getFullYear();
           var thisMonth=today.getMonth();
           for (var x=0; x<=thisMonth; x++) { // Use this if you want January to be first
           //for (var x=thisMonth; x>=0; x--) { // Use this if you want the current month to be first
                   var option = document.createElement('option');
                   option.value=thisMonth+1;
                   if (option.value=="<%=request.form("txtDate1")%>"){
                       option.setAttribute("selected", "selected");
                   }
                   var text = document.createTextNode(MONTHS[x]+'-'+thisYear);
                   option.appendChild(text);
                   document.getElementById('months').appendChild(option);
           }
    }
    </script>
    
    <select name="txtDate1" id="months">
    <option>---</option>
    </select>
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #14
    Regular Coder
    Join Date
    Feb 2006
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i've test it already....the combo box will automatically shows the current year no matter what user have been selected and click submit button.....

    can you please help me again????

    thank u very much.
    Last edited by tanhaha_how; 03-01-2006 at 07:02 AM.

  • #15
    Regular Coder
    Join Date
    Feb 2006
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I've changed to this code below.....but the the combo box will automatically jump to ---.....can anyone help me please??

    Code:
    <select name="txtDate1" id="months" value="<%=request("txtDate1")%>">
    <option value="0">---</option>
    <%
    txtDate3 = DatePart("yyyy", Date())
    Dim j
    For j=1 To Month(Date)
    %>
    <option value="<%=CStr(MonthName(j,true)) & "," & " " & CStr(txtDate3)%>" <%if CStr(request("txtDate1")) = CStr(MonthName(j,true)) and subop<>"cancel" then%>selected<%end if%>><%=CStr(MonthName(j,true)) & "," & " " & CStr(txtDate3)%></option>
    <%
    Next
    %>
    </select>
    Thanks in advance.


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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