...

View Full Version : onclick put a value into a textbox/inputfield



Null
12-12-2007, 12:15 PM
Okay this is the code (cut down):


==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

oesxyl
12-12-2007, 12:27 PM
Okay this is the code (cut down):


==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

Null
12-12-2007, 12:39 PM
Hi,

Thank you for your time.

This is what I have now:

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 :) )

oesxyl
12-12-2007, 12:49 PM
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.

Null
12-12-2007, 01:09 PM
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:


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

oesxyl
12-12-2007, 02:03 PM
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:


serial = $.SortSerialize('sortable1');
alert(serial.hash);

Does this help?
no, sorry



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, :D

best regards

Null
12-12-2007, 02:06 PM
No problem, thank you for your time, i'll be waiting :)

shakir
12-12-2007, 06:49 PM
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>

Null
12-12-2007, 08:06 PM
Well I do have a similar code that does work:

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:


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 :(



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum