SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    Don't get too close, I bite! Nicky's Avatar
    Join Date
    Jul 1999
    Location
    Lancashire, UK
    Posts
    8,277
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    The Caption Game

    Ok, I am trying to get a line of text that a user types into a textfield to appear somewhere else on the screen. AT teh moment when the user presses submit it refreshes the page and does write the text line to the screen but it is a brand new page and I lose all my content.

    HELP!

  2. #2
    ********* obeah makeda's Avatar
    Join Date
    Jun 2001
    Location
    rollin' on dubs
    Posts
    492
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Don't use:

    <input type="submit" />

    instead, use:

    <input type="button" />

  3. #3
    Don't get too close, I bite! Nicky's Avatar
    Join Date
    Jul 1999
    Location
    Lancashire, UK
    Posts
    8,277
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    That does nothing at all!

  4. #4
    ********* obeah makeda's Avatar
    Join Date
    Jun 2001
    Location
    rollin' on dubs
    Posts
    492
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Post some code. Are you trying to submit the page? Based on your description it sounded as though you didn't want it to. What kind of event handler are you using? I assumed you were doing something like this:

    <input type="button" onClick="YourFunction()" />

  5. #5
    Don't get too close, I bite! Nicky's Avatar
    Join Date
    Jul 1999
    Location
    Lancashire, UK
    Posts
    8,277
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Ok, here is the code for the entire page:

    Code:
    <html>
    <head>
    <title>Home</title>
    <LINK rel=stylesheet href="stylee.css" type="text/css">
    <script language="javascript">
    <!--
    var result="Preferred Route Out Of Town "
    function writer(){
    result = document.forms[0].scribe.value
    print()
    }
    function print(){
    document.write('<font type="arial" color="#ffffff">' + result + '</font>')
    }
    //-->
    </script>
    </head>
    <body>
    
    <img src="../pictures/oresundblue.jpg" alt="Bridging the gap between You and the Industry" height="250" width="250" align="right">
    
     <P> You can use this site to find details on products and companies specific to Bridge Construction and maintenance.
          If you have any problems finding what you need, look at the <a href="sitemap/sitemap.htm">Site Map</a>.
          For other information about this site <a href="contact.htm">click here</a>.
     <br>The Engineering WebLink is designed to give you information straight to your desktop. In some cases you will need internet access.
         This is true for links labelled with <img src="../pictures/icons/internet.gif" alt="Internet Needed" align="absmiddle">
    <p>
    <HR>
    <p>
    <table border="0" cellpadding="0" cellspacing="10">
    
      <TR>
        <TH colspan="3">
          <h1>Caption Competition</h1>
    		</TH>
      </TR>
    
    
      <TR>
        <TD width="200">
    	  <p>There is no prize to this because it's not difficult enough. Just for fun.
    	  <br>Suggest a caption to this picture.
    	    </TD>
    	<TD background="../pictures/trailersign.jpg" height="207" width="141" valign="top">
    	  <p>.<br>
    	  <script>
    	  print()
    	  </script>
    	    </TD>
        <TD>
          <p>Enter Your text here.
          <form onSubmit="writer()">
          <input type="text" name="scribe" size="30">
          <input type="submit" value="Enter">
          </form>
            </TD>
      </TR>
    
    
    
    
    
    
    
    </body>
    </html>

  6. #6
    ********* obeah makeda's Avatar
    Join Date
    Jun 2001
    Location
    rollin' on dubs
    Posts
    492
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK, and what do you want to have happen? Do you want the page to submit or not? If you want the page to submit, what do you want to happen after it does?

  7. #7
    Don't get too close, I bite! Nicky's Avatar
    Join Date
    Jul 1999
    Location
    Lancashire, UK
    Posts
    8,277
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    All I want is for the content to remain the same except here:
    Code:
        <TD width="200">
    	  <p>There is no prize to this because it's not difficult enough. Just for fun.
    	  <br>Suggest a caption to this picture.
    	    </TD>
    	<TD background="../pictures/trailersign.jpg" height="207" width="141" valign="top">
    	  <p>.<br>
    	  <script>
    	  print()
    	  </script>
    	    </TD>
    That should change to whatever the user types into the text field!

    Do I make sense?

  8. #8
    ********* obeah makeda's Avatar
    Join Date
    Jun 2001
    Location
    rollin' on dubs
    Posts
    492
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think so. So when the person clicks the button, you want to update the text but you don't want to submit the page. If that is correct, than this should work:

    Code:
    <html>
    <head>
    <title>Home</title>
    <LINK rel=stylesheet href="stylee.css" type="text/css">
    <script language="javascript">
    <!--
    var result="Preferred Route Out Of Town "
    function updateText(){
    
    document.all("spText").innerHTML = "<font type=\"arial\" color=\"#ffffff\">" + document.myForm.scribe.value + "</font>";
    }
    
    //-->
    </script>
    </head>
    <body>
    
    <img src="../pictures/oresundblue.jpg" alt="Bridging the gap between You and the Industry" height="250" 
    
    width="250" align="right">
    
     <P> You can use this site to find details on products and companies specific to Bridge Construction and 
    
    maintenance.
          If you have any problems finding what you need, look at the <a href="sitemap/sitemap.htm">Site 
    
    Map</a>.
          For other information about this site <a href="contact.htm">click here</a>.
     <br>The Engineering WebLink is designed to give you information straight to your desktop. In some cases 
    
    you will need internet access.
         This is true for links labelled with <img src="../pictures/icons/internet.gif" alt="Internet Needed" 
    
    align="absmiddle">
    <p>
    <HR>
    <p>
    <table border="0" cellpadding="0" cellspacing="10">
    
      <TR>
        <TH colspan="3">
          <h1>Caption Competition</h1>
    		</TH>
      </TR>
    
    
      <TR>
        <TD width="200">
    	  <p>There is no prize to this because it's not difficult enough. Just for fun.
    	  <br>Suggest a caption to this picture.
    	    </TD>
    	<TD background="../pictures/trailersign.jpg" height="207" width="141" valign="top">
    	  <p>.<br>
    	  <span id="spText" />
    	    </TD>
        <TD>
          <p>Enter Your text here.
          <form name="myForm">
          <input type="text" name="scribe" size="30">
          <input type="button" value="Enter" onCLick="updateText()">
          </form>
            </TD>
      </TR>
    
    </body>
    </html>

    The only way to see that this is working is to take out the color attribute, otherwise its white on white. Is that what you wanted?

  9. #9
    Don't get too close, I bite! Nicky's Avatar
    Join Date
    Jul 1999
    Location
    Lancashire, UK
    Posts
    8,277
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    It shouldn't be white on white because the image is black. Hang on I shall try out your code!

  10. #10
    ********* obeah makeda's Avatar
    Join Date
    Jun 2001
    Location
    rollin' on dubs
    Posts
    492
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Since you had this:

    <font type="arial" color="#ffffff">

    I figured you wanted white text. If you don't, just take the color attribute out of your font tag.

    Also, your exclamation marks are leading me to believe you are quite angry. If you don't want my help, just say so.

    EDIT--

    I didn't realize you had an image as your background. I wasn't picking it up locally.

  11. #11
    Don't get too close, I bite! Nicky's Avatar
    Join Date
    Jul 1999
    Location
    Lancashire, UK
    Posts
    8,277
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thanks, it works, you are a darling!

    Me - angry? IF you knew me you would know how far frmo the trught that is, I get stressed, I get tired, but I rarely get angry. I am just an exclamation mark whore! hee hee hee
    Last edited by Nicky; Feb 14, 2003 at 07:42.

  12. #12
    ********* obeah makeda's Avatar
    Join Date
    Jun 2001
    Location
    rollin' on dubs
    Posts
    492
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok.


Bookmarks

Posting Permissions

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