Its been a week I’ve been RnD on Java sciprt….:o I am looking for java script ,which will copy all HTML form fields in one click ( whatever we enter) and after that we can copy it to Notepad or anywhere ..
@felgallJul 31.2008 — #JavaScript has no access to anything outside the web browser. JScript can access the clipboard but that only runs on Internet Explorer.
Its been a week I've been RnD on Java sciprt....:o
I am looking for java script ,which will copy all HTML form fields in one click ( whatever we enter) and after that we can copy it to Notepad or anywhere ..
Appreciate your help?
[/FONT][/QUOTE]
ie7 blocked ie6's easy access. i have some code that might help.
is an ie6 or a firefox only solution acceptable for you, or is this for a public site?
@felgallAug 01.2008 — #A browser specific solution for one of the two or three browser versions that support it would be the only choice since most web browsers have that security hole closed off so that the single browser solutions will only work for an intranet site or where your visitor has their browser security set wrong.
@rnd_meAug 01.2008 — #A browser specific solution for one of the two or three browser versions that support it would be the only choice since most web browsers have that security hole closed off so that the single browser solutions will only work for an intranet site or where your visitor has their browser security set wrong.[/QUOTE]
yes. its a security pref in ie6: tools, internet options, security, custom level.
in forefox it's an about:config pref: signed.applets.codebase_principal_support needs to be true. this will then prompt you (with an optional remeber) to decide if you want the current page to be able to access your clipboard. i have mine set, and i have never seen a public page ask.
the following is a unified function for IE and firefox [CODE]
@felgallAug 02.2008 — #Your else clause also needs to test if the browser is the one that supports that code and is not one of the thousands of browsers that supports neither option.
I will put it more clearly now. I have a form which has 4 text fields. I can type in those text fields and when I click copy button( which will work like a clipboard function) it should copy all the text fields data.
I have done for 1 text field but problem comes when there is a more then 1 text field.:rolleyes:
@rnd_meAug 04.2008 — #Thanks Guys for your input..!!!
I will put it more clearly now. I have a form which has 4 text fields. I can type in those text fields and when I click copy button( which will work like a clipboard function) it should copy all the text fields data.
I have done for 1 text field but problem comes when there is a more then 1 text field.:rolleyes:
Hope I made it clear now...[/QUOTE]
you need to pass over each field, and extract the value to a string.
you then copy the resulting string. theres lots of ways to visit the fields.
if there are only four of them, the simplest way would likeley to give each one you need an id attrib.
then your code simply calls each element by id, and concats the value to a buffer.this point in the code this is a good change to cleanup/format the text.
From your code I can decipher that buffer value would be the abcd if I put a,b,c,d in t1,t2,t3,t4 respectively..hope I have understood correctly.
But I find confusing ,how to pass this buffer value to clipboard function..So that when I call clipboard function on click it should copy the buffer value and after that I can paste in Notepad..
From your code I can decipher that buffer value would be the abcd if I put a,b,c,d in t1,t2,t3,t4 respectively..hope I have understood correctly.
But I find confusing ,how to pass this buffer value to clipboard function..So that when I call clipboard function on click it should copy the buffer value and after that I can paste in Notepad..
@felgallAug 07.2008 — #You need to put some sort of separator in between the values. For example:
function copyEm(){ var b = []; b.push(el("t1").value); b.push(el("t2").value); b.push(el("t3").value); b.push(el("t4").value); var buffer = b.join(';'); CB(buffer); }
Which loads the values into an array and then joins the array values together with semi-colons in between