SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Wizard WorldNews's Avatar
    Join Date
    Nov 2007
    Posts
    1,033
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Trying to set the value of one form to be the same as the other

    Hi,

    I am trying to set the value of form with name:
    url2ix_2

    to be equal to that of:
    url2ix_1

    But although everything seems to be firing OK, the value of 2 is not changing to that of 1.
    Here are the related codes;

    function set_equal ($f, $ix)
    {

    var url_a = 'url2ix_' + $ix;
    var url_b = 'url2ix_' + ($ix + 1);

    alert('b = ' + url_b);

    f.url_b.value = f.url_a.value;

    }


    being called by:

    <input type="button" name="copy" Value="Copy" OnClick="set_equal(this.form, <?php echo $i; ?>)" class="form_button">

    what is the problem?

    ThanX

    Anoox search engine volunteer

    www.anoox.com

  2. #2
    SitePoint Guru
    Join Date
    Sep 2006
    Posts
    731
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Where do you define f ?

    Use the error console.
    Tab-indentation is a crime against humanity.

  3. #3
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,861
    Mentioned
    206 Post(s)
    Tagged
    12 Thread(s)
    Quote Originally Posted by Logic Ali View Post
    Use the error console.
    I wrote a short blog post on how to do this. Maybe that helps.

  4. #4
    SitePoint Enthusiast
    Join Date
    May 2011
    Posts
    55
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi WorldNews,

    Just check that before the value is getting assign, is there any error the above code or just try by calling the same function and only assign the field value in the function i.e

    function set_equal ($f, $ix)
    {

    f.url2ix_2.value = f.url2ix_1.value;

    }

    just check if this works...

  5. #5
    SitePoint Wizard WorldNews's Avatar
    Join Date
    Nov 2007
    Posts
    1,033
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Hey,

    Just wanted to let you know that resolved this with:

    function set_equal ($ix)
    {

    var url_s = 'ix_' + $ix;
    var url_e = 'ix_' + ($ix + 1);

    document.getElementById(url_e).value = document.getElementById(url_s).value;

    }

    Anoox search engine volunteer

    www.anoox.com


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
  •