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.
Results 1 to 9 of 9
  1. #1
    Senior Coder
    Join Date
    May 2004
    Posts
    1,466
    Thanks
    15
    Thanked 0 Times in 0 Posts

    form swapper -- please help

    I am using the form swapper found
    http://javascript.internet.com/forms...swapper-2.html

    The problem is that when I submit the form -- when (in asp) i do request.form("list2") -- it finds list2 as blank.

    Why? and what can I do to fix?

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Are you using POST as form method? If the method is not specified, the default is GET. You need to set it to POST to use Request.Form.
    Glenn
    ____________________________________

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

  • #3
    Senior Coder
    Join Date
    May 2004
    Posts
    1,466
    Thanks
    15
    Thanked 0 Times in 0 Posts
    yes i changed to post

    and anyway i tried with just request("list2") and its' teh same problem.

    what am i doing wrong? is this supposed to work for submitting.

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Is this an upload form? If it's an upload form, the form enctype is multipart/form-data and Request.Form will not work. Posting related codes will help.
    Glenn
    ____________________________________

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

  • #5
    Senior Coder
    Join Date
    May 2004
    Posts
    1,466
    Thanks
    15
    Thanked 0 Times in 0 Posts
    no a regular form

    <form name="handle" method="post" action=savetranslators.asp>

    then the list boxes and submit
    that's it

  • #6
    Senior Coder
    Join Date
    May 2004
    Posts
    1,466
    Thanks
    15
    Thanked 0 Times in 0 Posts
    ok -- what i was doing wrong was I wansn't selecting the items in the second box before submitting.

    Is there anyway to automatically have them all selected on submit?

  • #7
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Code:
    function selectAll(oSel){
      var len = oSel.options.length;
      for (var i=0; i<len; i++){
        oSel.options[i].selected = true;
      }
    }
    ...
    <form onsubmit="selectAll(this.list2)">
    But for a quick moment, the highlighting will be visible to the user.
    If that bothers you, you can just have a hidden text field that contains the added items.
    Code:
    function getSelectedItems(oSel){
      var len = oSel.options.length;
      var hid = oSel.form.hiddenList;
      for (var i=0; i<len; i++){
        hid.value = ((hid.value!="") ? "," : "") + oSel.options[i].value;
      }
    }
    ...
    <form onsubmit="getSelectedItems(this.list2)">
    <input type="hidden" name="hiddenList" />
    Then in action page, retrieve the value of the hidden field and not the combo box:
    Code:
    <%
    dim list, arrList
    list = request.form("hiddenList")
    arrList = split(list, ",")
    for each item in arrList
      response.write item & "<br />"
    next
    %>
    Glenn
    ____________________________________

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

  • #8
    Senior Coder
    Join Date
    May 2004
    Posts
    1,466
    Thanks
    15
    Thanked 0 Times in 0 Posts
    thanks for your help.

    I'm doing the hidden list option

    it is writing out in the asp

    ,297 (297 is the second id) it's basically not showing the first id selected -- or actaully always showing , and only one of the values.

  • #9
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Sorry I forgot the + sign.
    Code:
    for (var i=0; i<len; i++){
        hid.value += ((hid.value!="") ? "," : "") + oSel.options[i].value;
    }
    It's also good to reset the hidden field so that values don't add up when the page is submitted again.
    Code:
    hid.value = ""; //reset
    for (var i=0; i<len; i++){
        hid.value += ((hid.value!="") ? "," : "") + oSel.options[i].value;
    }
    Last edited by glenngv; 05-30-2005 at 02:30 PM.
    Glenn
    ____________________________________

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


  •  

    Posting Permissions

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