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
    New Coder
    Join Date
    Oct 2002
    Posts
    28
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question onclick put a value into a textbox/inputfield

    Okay this is the code (cut down):
    Code:
    ==some more functions and code here==
    
    function serialize(s)
    {
    	serial = $.SortSerialize(s);
    	alert(serial.hash);
    };
    </SCRIPT>
    
    <form action="" method="post">
      <input name="serial" id="serial" value="" />
      <p class="submit alignleft"><input type="submit" onclick="serialize(); " value="Update" /></p>
    </form>
    What happens?
    When I click the submit button a string ($.SortSerialize(s)) will be shown in an alertbox (on click).

    What do I want?
    I want this string to appear in my textbox/inputfield and not in the alertbox.

    I know that the alert(serial.hash); has to be removed from the code, but still no luck then

    Hope someone can help me with this...

    _Null
    Last edited by Null; 12-12-2007 at 11:17 AM.

  • #2
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by Null View Post
    Okay this is the code (cut down):
    Code:
    ==some more functions and code here==
    
    function serialize(s)
    {
    	serial = $.SortSerialize(s);
    	alert(serial.hash);
    };
    </SCRIPT>
    
    <form action="" method="post">
      <input name="serial" id="serial" value="" />
      <p class="submit alignleft"><input type="submit" onclick="serialize(); " value="Update" /></p>
    </form>
    What happens?
    When I click the submit button a string ($.SortSerialize(s)) will be shown in an alertbox (on click).

    What do I want?
    I want this string to appear in my textbox/inputfield and not in the alertbox.

    I know that the alert(serial.hash); has to be removed from the code, but still no luck then

    Hope someone can help me with this...

    _Null
    function serialize(s) is declare with 1 argument and in onclick has no argument.

    you must retrive the value of s from input and use it with something like that:

    var s = document.getElementById('serial');

    s.value is what you need.

    best regards

  • #3
    New Coder
    Join Date
    Oct 2002
    Posts
    28
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Hi,

    Thank you for your time.

    This is what I have now:
    Code:
    function serialize(s)
    {
    	serial = $.SortSerialize(s);
    	var s = document.getElementById('sort3');
    	
    };
    </SCRIPT>
    
    <form action="" method="post">
      <input name="serial" id="serial" value="" />
      <p class="submit alignleft"><input type="submit" onclick="serialize('sort3');" value="Update" /></p>
    </form>
    It doesn't work. I am kinda noob with this stuff so I probably misunderstood you and put some code at the wrong place. Can you give me a code example perhaps? (I feel I am soo near at making this work )

  • #4
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts

    Lightbulb

    Code:
    function serialize()
    {
    	var s = document.getElementById('sort3');
            // and now do what you want to do with s.value
            ....
    	serial = $.SortSerialize(s.value);
    };
    </SCRIPT>
    
    <form action="" method="post">
      <input name="serial" id="serial" value="" />
      <p class="submit alignleft"><input type="submit" onclick="serialize();" value="Update" /></p>
    </form>
    I don't know what is $.SortSerialize... and what it means so I can't help with that.

  • #5
    New Coder
    Join Date
    Oct 2002
    Posts
    28
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Hi,

    SortSerialize

    This function returns the hash and an object (can be used as arguments for $.post) for every sortables in the page or specific sortables. The hash is based on the 'id' attributes of container and items.

    Code sample:

    Code:
    serial = $.SortSerialize('sortable1');
    alert(serial.hash);
    Does this help?

    I also have a demo for the whole html file, this will make things clearer i think:
    http://www.sourceskins.com/test.zip

    Note: that there are more alert request in this file but it needs to be just 1, like serialize list 3.

    _Null
    Last edited by Null; 12-12-2007 at 12:35 PM.

  • #6
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by Null View Post
    Hi,

    SortSerialize

    This function returns the hash and an object (can be used as arguments for $.post) for every sortables in the page or specific sortables. The hash is based on the 'id' attributes of container and items.

    Code sample:

    Code:
    serial = $.SortSerialize('sortable1');
    alert(serial.hash);
    Does this help?
    no, sorry

    Quote Originally Posted by Null View Post
    I also have a demo for the whole html file, this will make things clearer i think:
    http://www.sourceskins.com/test.zip

    Note: that there are more alert request in this file but it needs to be just 1, like serialize list 3.

    _Null
    I download that zip and later when I have more time, I'll try to see what it is.

    Anyway that does not mean that I'll understand what is,

    best regards

  • #7
    New Coder
    Join Date
    Oct 2002
    Posts
    28
    Thanks
    1
    Thanked 0 Times in 0 Posts
    No problem, thank you for your time, i'll be waiting

  • #8
    Regular Coder
    Join Date
    Nov 2007
    Posts
    110
    Thanks
    0
    Thanked 1 Time in 1 Post
    In submit button you cant add javascript. So change to normal button.just copy and paste below then check

    <script>
    function serialize()
    {
    document.frm.serial.value="Hello";
    }
    </script>
    <form name ="frm" method="post">
    <input name="serial" id="serial"/>
    <p class="submit alignleft"><input type="button" onclick="serialize() " value="Update" /></p>
    </form>

  • #9
    New Coder
    Join Date
    Oct 2002
    Posts
    28
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Well I do have a similar code that does work:
    Code:
    function getSort() {
    order = document.getElementById("order");
    order.value = DragDrop.serData('g1', null);
    }
    </script>
    
    <form action="" method="post">
    <input name="order" id="order" value="" />
    <p class="submit alignleft"><input type="submit" onclick="getSort()" value="Update" /></p>
    </form>
    This works so how to let/transform:

    Code:
    function serialize(s)
    {
    	serial = $.SortSerialize(s);
    	alert(serial.hash);
    };
    </script>
    <form action="" method="post">
    <input type="hidden" name="order" id="order" value="" />
    <p class="submit alignleft"><input type="submit" onclick="getSort()" value="Update" /></p>
    </form>
    To do the same? Still no luck


  •  

    Posting Permissions

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