Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Printing Hidden Field Values
Old 02-02-2009, 12:05 PM Printing Hidden Field Values
sepple's Avatar
Super Talker

Posts: 147
Trades: 0
Is it possible to have a hidden field at the top of a page and then be able to show the value of that hidden field in the body of that same page?
__________________
Thanks
Stephen
sepple is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-02-2009, 12:46 PM Re: Printing Hidden Field Values
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
if by "field" you mean any area with content in it, then sure.

HTML Code:
<html>
<head>
<h1>Tricky Dick</h1>
<head>
<body>
<div id="hidden" style="display:none;">
Some content
</div>
<div id="content">
</div>
<script>
document.getElementById("content").innerHTML = document.getElementById("hidden").innerHTML;
</script>
</body>
</html>
Why you would want to do this is beyond me. I suspect you think there is some SEO benefit, which is highly suspect. In addition, it will only work if JavaScript is enabled. When disabled, nothing will show in the second div ("content").
__________________
Join me on
Please login or register to view this content. Registration is FREE

Last edited by wayfarer07; 02-02-2009 at 12:49 PM..
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 02-02-2009, 12:56 PM Re: Printing Hidden Field Values
sepple's Avatar
Super Talker

Posts: 147
Trades: 0
This is not for SEO at all.

I have:
Code:
<input type="hidden" id="first_name" value='Stephen' />
And want to be able to print that value lower on the page.

Can I do:

Code:
document.write(document.getElementById("first_name").innerHTML);
or

Code:
document.getElementById("first_name").innerHTML = the_first_name;

document.write (the_first_name);
And thanks for the help!!
__________________
Thanks
Stephen

Last edited by sepple; 02-02-2009 at 12:58 PM..
sepple is offline
Reply With Quote
View Public Profile
 
Old 02-02-2009, 01:05 PM Re: Printing Hidden Field Values
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
ah, I see. In this case you would just use .value instead of .innerHTML , as long as there is an ID attribute. If you want to document.write it, that is fine, as long as the statement appears after the hidden field in the markup.
__________________
Join me on
Please login or register to view this content. Registration is FREE
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 02-05-2009, 12:27 PM Re: Printing Hidden Field Values
spyderwebtech's Avatar
Skilled Talker

Posts: 51
Trades: 0
If you want to print a user's name somewhere else on the page,then why don't you do this on the server side, using PHP. Ideally, that hidden value has to come from somewhere initially.
spyderwebtech is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Printing Hidden Field Values
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.15389 seconds with 12 queries