/    Sign up×
Community /Pin to ProfileBookmark

How do I add a value into an input field

I need to put a cookie value into a form input field using Javascript.

The form is written in php and I have no way to change the code or change the name of the input field.

I have a Cookie function that gets the cookie (get_Cookie). the Cookie name is “Referredby”.

The form name is “editform” and the input field name is “FormField[2][32]”

Would this be the correct way to put the value of the cookie into the form field?

[CODE]<script type=”text/javascript”>
function putcookie() {
var refer = ( get_Cookie( ‘Referredby’ ) );
document.forms[“editform”].elements[“FormField[2]”][32] = refer;
}
</script>[/CODE]

Thanks for your help

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@Sales_TrainiauthorApr 28.2010 — Can anyone help me?
Copy linkTweet thisAlerts:
@ChipzzzApr 28.2010 — w3schools has a pretty detailed description of javascript cookie handling here: http://www.w3schools.com/JS/js_cookies.asp .

I hope it helps ?

Chipzzz
×

Success!

Help @Sales_Traini spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...