SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2007
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Form's Input Pattern

    I'm tired to re-coping and then re-pasting the same part of the sentence in the Value of the Input over and over again.

    <form action= "method="post">
    <input type="text" name="example" value="samepartNEWWORDsamepart" />
    </form>

    Is it possible to enter only NEWWORD in the form's box, but to hide samepart until the submition button of the form will be pressed on?

    Please help me to solve this one. Thank you in advance.

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,258
    Mentioned
    196 Post(s)
    Tagged
    2 Thread(s)

    parts

    Maybe something like
    PHP Code:
    $var "samepart" $_POST['example'] . "samepart";
    // samepartNEWWORDsamepart 

  3. #3
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Without a complicated JS solution, I dont think so.

    you could pass the information onto the end using something like this ....
    PHP Code:
    <form action"method="post">
    <input type="
    text" name="example" value="NEWWORD" />
    <input type="
    hidden" name="pretext" value="this" />
    <input type="
    hidden" name="posttext" value="that" />
    </form> 
    then on backend:

    $input_box = $_POST['pretext'] . $_POST['example'] . $_POST['posttext'] ;

    // echo $input_box
    // gives the following if the users doesnt type anything in the text box
    thisNEWWORDthat

  4. #4
    SitePoint Enthusiast
    Join Date
    Feb 2007
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you for your prompt replies. Yeah, it's not that ease as I thought. Is it possible to accomplish this with:

    eregi_replace

  5. #5
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Perhaps you could explain a little more about why you want to append and prepend text to a text box, whats the reason?

  6. #6
    SitePoint Enthusiast
    Join Date
    Feb 2007
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you for your involvement. Here you go:

    I work on my Control Management System, and I created a form with input boxes in it, where I have to enter new web-page addresses for new pages of my website.

    <form action= "method="post">
    <input type="text" name="example" value="<a href="http://www.example.com/NEWWORD.htm" target="_blank"><img src="http://www.example.com/images/NEWWORD.gif" alt="NEWWORD" /></a>" />
    </form>

    As you can see I have to be very careful if I copy the (value) part of the (input) and then to paste only NEWWORD in it. I try to find the easiest way how to accomplish that with one insert command inside to the (value) line.
    Last edited by metrosky; Apr 16, 2007 at 13:12.

  7. #7
    SitePoint Enthusiast
    Join Date
    Feb 2007
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ^

  8. #8
    Who turned the lights out !! Mandes's Avatar
    Join Date
    May 2005
    Location
    S.W. France
    Posts
    2,496
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Sorry I think your stuck with good old fashioned hard work and key bashing
    A Little Knowledge Is A Very Dangerous Thing.......
    That Makes Me A Lethal Weapon !!!!!!!!

    Contract PHP Programming

  9. #9
    code ninja hamstu's Avatar
    Join Date
    Nov 2002
    Location
    Montréal, Canada
    Posts
    375
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm, why wouldn't you just make the string once your form is submitted?
    PHP Code:
    $mycode '<a href="http://www.example.com/' $newword '.htm" target="_blank"><img src="http://www.example.com/images/' $newword '.gif" alt="' $newword '" /></a>' 
    Where $newword is from your $_POST.

  10. #10
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,258
    Mentioned
    196 Post(s)
    Tagged
    2 Thread(s)

    copy - paste

    If you have a lot of "copy - paste" to do maybe you could use PHP to generate the inputs instead. eg. something like
    PHP Code:
    $new_words = array('contact''about''pictures''songs''poems''stories');
    foreach(
    $new_words as $key => $value) {
    echo 
    "<input type=\"text\" name=\"example\" value=\"<a href=\"http://www.example.com/" $value ".htm\" target=\"_blank\"><img src=\"http://www.example.com/images/" $value ".gif\" alt=" $value " /></a>\" />";

    BTW - does using an image link as an input value work?

  11. #11
    SitePoint Enthusiast
    Join Date
    Feb 2007
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I feel that I'm on the right track.
    I'm kinda new to PHP, therefore sorry for my probably simple to you question.

    for this PHP Code:

    $new_words = array('contact', 'about', 'pictures', 'songs', 'poems', 'stories');
    foreach($new_words as $key => $value) {
    echo "<input type=\"text\" name=\"example\" value=\"<a href=\"http://www.example.com/" . $value . ".htm\" target=\"_blank\"><img src=\"http://www.example.com/images/" . $value . ".gif\" alt=" . $value . " /></a>\" />";
    }


    It's what I have to put into the Input Line?


    <input type="text" name="new_words" value="NEWWORD"/ size="150" />
    Last edited by metrosky; Apr 16, 2007 at 18:53.


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
  •