SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    Non-Member
    Join Date
    Aug 2007
    Posts
    494
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problem with form in window popup

    Hi all.

    I have this JavaScript function that copy the value ( selected in a select open in a window popup), in the hidden main form field.

    I need this changes:

    1) If the popup window is not requested by the user, the hidden main form field take value = 0;
    2) If the window is open to force the user to make a choice within the select.

    Can you help me?
    Thanks

    Code:
    <script language="javascript" type="text/javascript">
    <!--
     
    function setValue(selObj)
    {
        
      if (!window.opener || selObj.selectedIndex <= 0) return;
     
      var vl = "";
      var opts = selObj.options;
     
      for ( n = 0 ; n < opts.length ; n++ )
        {
          if (opts[n].selected)
            {
              if (vl.length > 0) vl += ", ";
              vl += opts[n].value;
            }
        }
      
      window.opener.document.Qform.NASCOSTO.value = selObj.value;
      
       
      window.close();
    
    }
     
    // -->
    </script>

  2. #2
    SitePoint Enthusiast
    Join Date
    Oct 2007
    Posts
    97
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    This is what you can do: -

    1) If the popup window is not requested by the user, the hidden main form field take value = 0;

    Check if the submit button has not been clicked then before opening the new window set the value of the hidden filed to '0'.

    2) If the window is open to force the user to make a choice within the select.

    Check if the window is already open then close it and show a alert for user to select something from the select box.

    Hope this helps.

    Cheers,

    ~Maneet
    Maneet Puri
    Lexolution IT Services

  3. #3
    Non-Member
    Join Date
    Aug 2007
    Posts
    494
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for your helps... but I need example, modifying the my function javascript... sorry

  4. #4
    Non-Member
    Join Date
    Aug 2007
    Posts
    494
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)


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
  •