SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Zealot superbrava's Avatar
    Join Date
    Aug 2001
    Location
    Indianapolis, IN
    Posts
    104
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need help with sending info from a input field to a textarea onBlur()

    i am making a generator to print metatags. instead of using php to do this, i decided i want to use javascript. what i want to do is when a user puts something in a input field, after they change focus to another one, it places the value in the textarea...well their values and the value of the metatag itself.

    say they put "name" for the "author" input field.

    i want to put "<meta name="author" content="name">" in the textarea.

    how would i do this?
    Steve v3.2.2 running on LocalSuck port 80

  2. #2
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    try moshe!!!

    Dont know much about forms, but I have used this to show result from a description Array.....

    description1="a red cat"
    description2="a blue horse!!"


    document.all.moshe.innerText=description1(any variable, numeric or lettered)

    then in HTML

    <span id="moshe" name="moshe">description2</span>

    I hope this will be of use....

  3. #3
    American't awestmoreland's Avatar
    Join Date
    Sep 2002
    Location
    Grand Rapids, MI
    Posts
    1,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think I've solved most of your problem (if I understand it correctly).

    This script takes the contents of the input field and onBlur it concatenates it with the tags and puts the value in the ouptut field.

    So far so good...

    ...however, I haven't been able to find a way to output the double-quote characters as they keep being interpreted. I know that \" should work, but it doesn't seem to be doing.

    Anyway, I'm sure that you can suss that bit out ;-)

    PHP Code:
    <!-- Put this in the body of your html page -->
    <
    form name="demo">
      <
    p>
            
    Input: <INPUT
            type
    ="text" 
            
    name="inP"
            
    size=40
            onBlur
    ="document.demo.out.value='&lt;meta name=' + document.demo.inP.value + ' content=name&gt;'">
      </
    p>
        <
    p>
            
    Output: <INPUT
            type
    ="textarea"
            
    name="out"
            
    size=40>
      </
    p>
    </
    form
    See it in action
    (Ignore the errors in the page, ProHosting appear to be trying to put popups in my page now)

    Andy

  4. #4
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    had a go, moshe's OK!!!

    copy and paste this.....its got &#34;'s as well


    <form name="demo">
    <p><input type="text" name="email" size="40"
    onBlur="document.all.moshe.innerText='&#34;<meta name=&#34;author&#34;'+[document.demo.email.value]+'&#34;content=&#34;name&#34;>&#34;'"
    </p>
    </form>

    <SPAN id="moshe" name="moshe">inP</SPAN>

  5. #5
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    sorry " = & # 34 ; (no spaces)

    sorry " = & # 34 ; (no spaces)

  6. #6
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    sorry, take the spaces out between the &,# and 34, that will make it ok
    This stops the use of square boxes around ouput!!!


    <form name="demo">
    <p><input type="text" name="email" size="40"
    onBlur="document.all.moshe.innerText='& # 34;<meta name=& # 34;author& # 34;'+[document.demo.email.value]+'& # 34; content=& # 34;name& # 34;>& # 34;'"
    </p>
    </form>

    <SPAN id="moshe" name="moshe">inP</SPAN>

  7. #7
    American't awestmoreland's Avatar
    Join Date
    Sep 2002
    Location
    Grand Rapids, MI
    Posts
    1,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Got there eventually

    Have now made a note of the escape character for double-quotes.


    Cheers,

    Andy


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
  •