Results 1 to 7 of 7

Thread: how to input the text in a document?

Hybrid View

  1. #1
    Join Date
    Sep 2008

    how to input the text in a document?

    Hi guys,

    I am working on my javascript to create the text in the html document. I want to know how I can write the text in html?

    I tried to use this:

    var test=myFunction();
    function myFunction(test)
      var keycode;
      if (window.event) keycode = window.event.keyCode;
        document.write("hello! this is a test");

    It did not write the text in the html. I tried to find the solution but i can't.

    Can you please help me?

    thanks in advance.

  2. #2
    Join Date
    Dec 2005
    If you call the function after the page has been rendered,
    the document.write will re-load the page as if you had never been there before.

    Consider using an alert if it is truly only a test.
    Or write to a visible element, like a <div> tag.
    Last edited by JMRKER; 03-26-2013 at 08:42 PM.

  3. #3
    Join Date
    Sep 2008
    No, I did not know about the document.write. I never had that score.

    Do I need to create a <span> to create the text in HTML and then enable\disable it using with javascript??

  4. #4
    Join Date
    Dec 2005
    Quote Originally Posted by mark107 View Post
    No, I did not know about the document.write. I never had that score.

    Do I need to create a <span> to create the text in HTML and then enable\disable it using with javascript??
    I'm not sure what it is that you are trying to accomplish in post #1
    Can you describe your requirement a bit better.

    I believe rthe window,event will only work in MSIE only anyway.

  5. #5
    Join Date
    Sep 2008
    well i am trying to create the text using with javascript. however, i am not aware that i need to create the text using with span in html so i created a text. I have got a problem, the text did not appear on my webpage after I wrote this in my javascript:

    text1.style.visibility = "visible";

    Here is the span tag I have input in the html page:

    <span id="text1"><span style="font-family:Arial;font-size:13px;font-style:normal;font-weight:normal;text-decoration:none;text-transform:none; position:absolute; visibility:hidden; overflow:hidden; left:50px; top:40px; width:376px; height:90px; z-index:0">this is a text </span></span>
    Do you have any idea how to display them in my webpage?

  6. #6
    Join Date
    Sep 2008
    Jackson MS
    One of my early pages (no forms or table) called a function that wrote the time difference as document.write()s. The body contained
    It's been
    <SCRIPT language=JavaScript>
    compDate("August 29, 2005 09:00");
     since Katrina slammed into Mississippi and Louisiana on Aug. 29, 2005 at about
    and it's output today (Mar 27, 2013 4pm.) is

    It's been 7 years, 6 months, and 29 days since Katrina slammed into Mississippi and Louisiana on Aug. 29, 2005 at about 9am.

    The whole page is compdate.htm.
    Also have a webpage that writes a narrative on round robin pairings into a text area on a form wyorrp.htm, but that might not be exactly what you need.

  7. #7
    Join Date
    Oct 2010
    Versailles, France
    Simply use a tag : container (div), paragraph (p) or a span with an id to write

    document.getElementById('myTag').innerHTML='Something to insert in the document';

    Since try this script which give this page :
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <meta name="generator" content="PSPad editor, www.pspad.com">
    <style type="text/css">
    #pge{display:block;width:400px;margin:0 auto;}
    #pge p,input {text-align:center;}
    <div id="pge"><fieldset><legend>How long ?</legend>
    <p>Enter a date (year, month day)
    <br>with separators or leading zéros
    <p><input type="text" id="dte">&nbsp;<a href="Javascript:displayResult()">Ok !</a></p>
    <p id="rsp"></p>
    <script type="text/javascript">
    function displayResult(){
    	var str=document.getElementById('dte').value, month, date, year;
    	var rgx=/\s*([1-9][0-9]{3})[\D]*(\d|\d\d)[\D]*(\d|\d\d)\s*/;
    	// A replace method with an anonymous function to define year, month and date 
    	// This function arguments are defined by the system 
    	// the matched string and the sub-patterns delimited by brackets (corresponds to $0, $1 $2...) 
    	var rsp=document.getElementById('rsp');
    	if (isNaN(month)) {rsp.innerHTML='Please, enter a valid date with digits, separators or leading zeros (YYYY/M/D or YYYYMMDD)';return}
    	var dat=new Date(year, month-1, date);
    	if (dat.getMonth()!=month-1) {rsp.innerHTML='Sorry, this date seems not valid !';return}
    	else {document.getElementById('rsp').innerHTML='';
    		var tdy=new Date(),deltaYear=deltaMonth=deltaDay=0;
    	   	 //  For the past
    		if (dat.valueOf()<tdy.valueOf()) {
    			if (tdy.valueOf()<dat.setFullYear(tdy.getFullYear()).valueOf()) {deltaYear--;}
    			while(dat.setMonth(dat.getMonth()+1).valueOf()<tdy.valueOf()) deltaMonth++;
    			while(dat.setDate(dat.getDate()+1).valueOf()<tdy.valueOf()) deltaDay++;
    		document.getElementById('rsp').innerHTML='It’s been '+deltaYear+' years, '+deltaMonth+' months, and '+deltaDay+' days since this date';			
    I'll let you fill in the dates of future...
    Last edited by 007Julien; 03-29-2013 at 05:26 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.11151 seconds
  • Memory Usage 3,109KB
  • Queries Executed 13 (?)
More Information
Template Usage (31):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (5)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (7)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)postbit_wrapper
  • (1)showthread_list
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (27):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./includes/functions_threadedmode.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (71):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids_threaded
  • showthread_threaded_construct_link
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates