56 users online (0 members and 56 guests)  


Page 2 of 2 First 1 2
  Results 16 to 22 of 22

Related

  1. Checkboxes and arrays    Forum: Javascript Forum
    Replies: 18
  2. Problem with forms    Forum: HTML Forum
    Replies: 1
  3. operations with files and arrays    Forum: PHP Forum
    Replies: 4
  4. Replies: 0
  1. #16
    rangana's Avatar
    Moderator/Allstar

    Status
    Offline
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    317

    Re: Problem with arrays and forms

    Could you please show us the code that you have now at your end.
    Checkout my porfolio.
    Please click the button when a member helped you.
    Take time to use Forum's Search function.

  2. #17
    adamsen's Avatar
    Senior Member

    Status
    Offline
    Join Date
    Jan 2009
    Location
    Denmark
    Posts
    128

    Re: Problem with arrays and forms

    Hi rangana, iīve been a little busy, but here I am.

    I have to sites
    1. urlpost.html
    2. recieve.html

    urlpost.html:
    HTML Code:
    <script type="text/javascript">
    function post()
    {
    [some code that validates some data and saves it into an array (not important now, just make an array and give it some values)];
    [code which posts the array to recieve.html];
    location.href="recieve.html";
    }
    </script><input type="button" value="send array" onclick="post()" />
    recieve.html:
    HTML Code:
    <body onload="recievearray()"><script type="text/javascript">
    function recievearray()
    {
    [some code which recieves the posted array and writes it in the textarea named recieve];
    }
    </script><textarea name="recieve" /></body>

  3. #18
    rangana's Avatar
    Moderator/Allstar

    Status
    Offline
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    317

    Re: Problem with arrays and forms

    Not sure what you're trying to do here, but you need to pass the elements in a way that the other page could read it.

    It could either be via cookies or by using the URL.

    I would prefer the former, as it's more decent, but since you are looking for a URL part, then you need to pass your array on this part:
    Code:
    location.href="recieve.html?arr="+arrayName;
    ...where arrayName is the name of your array.

    On your receive.html, you could fetch the value of the URL, by:
    Code:
    var urlArr = location.href.split('arr=')[1];
    document.recieve.value = urlArr;
    Hope that makes sense.
    Checkout my porfolio.
    Please click the button when a member helped you.
    Take time to use Forum's Search function.

  4. #19
    adamsen's Avatar
    Senior Member

    Status
    Offline
    Join Date
    Jan 2009
    Location
    Denmark
    Posts
    128

    Re: Problem with arrays and forms

    Thanks rangana, it works.

  5. #20
    adamsen's Avatar
    Senior Member

    Status
    Offline
    Join Date
    Jan 2009
    Location
    Denmark
    Posts
    128

    Re: Problem with arrays and forms

    Hi coothead

    I know you donīt have anything to do with this thread, but I have to mix these to things. Rangana helped me with some code which could "transfer" an array to another document. But this code doesnīt work in the checkbox-calendar.
    I have tried to insert this code in the calendar-tree-array-creater (from the thread about checkboxes and arrays). In kalender.js Iīve inserted this:

    HTML Code:
    location.href="recieve.html?arr="+numbers;
    window.location.href='dates.html'
    And in recieve.html I`ve inserted this:

    HTML Code:
    <input type="text" name="dates" size="25" id="dates">
    
    <script type="text/javascript">
    var urlArr = location.href.split('arr=')[1];
    document.recieve.value = urlArr;
    document.getElementById('dates').value = urlArr;
    </script>
    But when i arrive to recieve.html, nothing happens. I run this on my PC and not on a server, is it because of that? Or is there something wrong with the code?
    Last edited by adamsen; 05-19-2009 at 09:52 AM.

  6. #21
    rangana's Avatar
    Moderator/Allstar

    Status
    Offline
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    317

    Re: Problem with arrays and forms

    Though you address the question to coothead, I have some thought though.

    My best bet is that highlighted in the code is erroneous:
    Code:
    var urlArr = location.href.split('arr=')[1];
    document.recieve.value = urlArr;
    document.getElementById('dates').value = urlArr;
    If "recieve" is an element name, you can't access using that notation. You either need to pass through the form element or us "getElementsByName" having the first index (assuming it's only one element), or better assign an ID and use "getElementById()" instead.

    Hope that helps.
    Checkout my porfolio.
    Please click the button when a member helped you.
    Take time to use Forum's Search function.

  7. #22
    adamsen's Avatar
    Senior Member

    Status
    Offline
    Join Date
    Jan 2009
    Location
    Denmark
    Posts
    128

    Re: Problem with arrays and forms

    I canīt see what you mean.
    What code do I have to insert?



Page 2 of 2 First 1 2

Tags for this Thread