SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Zealot
    Join Date
    Mar 2005
    Posts
    166
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to add new values into a select option list

    Hello all,

    Someone could guide me to a code that inserts new values into a select option input on parent form via popup..
    I tried the codes below already..

    function sendInfo(pat)
    {
    opener.forminclui.tipo_chamado.options.text = pat;
    opener.forminclui.tipo_chamado.options.value = pat;

    self.close();
    }
    >>> In this case nothing happens...

    function sendInfo(pat)
    {
    opener.forminclui.tipo_chamado.options = pat;

    self.close();

    >>> In this case the change field only works if using a text input...whn using select inputs, it changes to blank...

  2. #2
    SitePoint Guru
    Join Date
    Sep 2006
    Posts
    731
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mjunior
    Hello all,

    Someone could guide me to a code that inserts new values into a select option input on parent form via popup..
    I tried the codes below already..

    function sendInfo(pat)
    {
    opener.forminclui.tipo_chamado.options.text = pat;
    opener.forminclui.tipo_chamado.options.value = pat;

    self.close();
    }
    >>> In this case nothing happens...

    function sendInfo(pat)
    {
    opener.forminclui.tipo_chamado.options = pat;

    self.close();

    >>> In this case the change field only works if using a text input...whn using select inputs, it changes to blank...
    Google: javascript +add +option +select

  3. #3
    SitePoint Zealot
    Join Date
    Mar 2005
    Posts
    166
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    I'm kind of lost..could you help me?

    I tried
    function sendInfo(pat)
    {

    opener.forminclui.tipo_chamado.options[1] = new Option(pat,pat);
    self.close();
    }

    Also nothing happens..

  4. #4
    SitePoint Guru
    Join Date
    Sep 2006
    Posts
    731
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mjunior
    I tried
    function sendInfo(pat)
    {

    opener.forminclui.tipo_chamado.options[1] = new Option(pat,pat);
    self.close();
    }

    Also nothing happens..
    assuming forminclui is a form, try addressing it:

    opener.document.forms.forminclui.tipo_chamado.options[1]

    I assume you are getting no console errors?

  5. #5
    SitePoint Zealot
    Join Date
    Mar 2005
    Posts
    166
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    still the same..

    Yes, the "forminclui" is the form name from my parent page...

    In this form has a window.open link to open a popup..
    In a popup I do a few rs researching and insert new data into my db..
    Then I'd like to send this new value added back to my parent form (inside my select option list)..but without reloading the page..

    As I said..I did the test using the sendInfo function pointing to text fields and the new data appears into the field normaly...

    Using the reference you sent to the parent page..the situation is the same,when I call the funtion by the OnClick method..nothing happens..
    Last edited by mjunior; Oct 21, 2006 at 16:54.

  6. #6
    SitePoint Guru
    Join Date
    Sep 2006
    Posts
    731
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mjunior
    Yes, the "forminclui" is the form name from my parent page...

    In this form has a window.open link to open a popup..
    In a popup I do a few rs researching and insert new data into my db..
    Then I'd like to send this new value added back to my parent form (inside my select option list)..but without reloading the page..

    As I said..I did the test using the sendInfo function pointing to text fields and the new data appears into the field normaly...

    Using the reference you sent to the parent page..the situation is the same,when I call the funtion by the OnClick method..nothing happens..
    You need to call the opener's Option function:
    Code:
    new opener.Option(...)

  7. #7
    SitePoint Zealot
    Join Date
    Mar 2005
    Posts
    166
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    still nothing

    Thanks for the quick reply..but I got nothing so far from this code:

    function sendInfo(pat)
    {

    opener.document.forms.forminclui.tipo_chamado.options[1] = new opener.Option( pat,pat);
    self.close();
    }

  8. #8
    SitePoint Guru
    Join Date
    Sep 2006
    Posts
    731
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mjunior
    Thanks for the quick reply..but I got nothing so far from this code:

    function sendInfo(pat)
    {

    opener.document.forms.forminclui.tipo_chamado.options[1] = new opener.Option( pat,pat);
    self.close();
    }
    It works in Opera and FireFox but I.E. says 'object does not support this action'.

    The solution is to have a function in the opener that updates the select.
    Code:
    function updateSelect(s)
    {
     document.forms.forminclui.tipo_chamado.options[1]=new Option(s,s);
    }
    and call it from the new window
    Code:
    opener.updateSelect(pat,pat)

  9. #9
    SitePoint Zealot
    Join Date
    Mar 2005
    Posts
    166
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Very tricky!!!

    Thanks mate..

    I also added the focus to that select...
    opener.forminclui.tipo_chamado.focus();


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
  •