www.webdeveloper.com
Results 1 to 10 of 10

Thread: [RESOLVED] (newbie) editing html elements from php form data ?? any one ?

  1. #1
    Join Date
    Aug 2012
    Posts
    5

    resolved [RESOLVED] (newbie) editing html elements from php form data ?? any one ?


    hi, i'm a newbie to php, i'm writing a a script right now but i'm stuck at this situation..

    i want visitors to edit a specific html elements through a form in another page coded with php or any other suitable language for this purpose

    explanation:

    let's say the index.html page has a paragraph like

    HTML Code:
    <p>XXXXXXXXXXX</p>
    i want visitors to edit this paragraph through a form like:



    Paragraph : |___________|

    [submit]


    and the XXXXXXXXXXX changes

    i hope you get the question and answer it quickly cuz I'm in grave need of it..
    thank you in advance

  2. #2
    Join Date
    Jun 2008
    Location
    Europe
    Posts
    1,114
    PHP Code:
    <h2>Enter your text in the form</h2>
    <form name="form1" method="post" action="">
    <input type="text" name="something" size="36" /> &nbsp;&larr; Enter some short text here.<br />
    <textarea rows="3" cols="55" name="text"></textarea> &nbsp;&larr; Enter long text here.<br />
    <input type="submit" value="Go" />
    </form>
    <div id="mydiv" name="mydiv">
    <?php

    $something 
    $_POST['something'];
    $text $_POST['text'];

    if(empty(
    $something) && empty($text)) {
    echo 
    'XXXXXXXXX - This is some text - XXXXXXXXXXXXX';
    } else {

    echo <<<EOD
    <b>$something</b><br /> $text
    EOD;

    }

    ?>
    </div>
    Last edited by donatello; 08-20-2012 at 05:44 AM.

  3. #3
    Join Date
    Jun 2008
    Location
    Europe
    Posts
    1,114
    You can also do it with JavaScript... depending upon what your intentions are...

    http://jsfiddle.net/z5pgG/

    Check out the JSFiddle which demonstrates it in simple Javascript.

  4. #4
    Join Date
    Aug 2012
    Posts
    5
    i'm sorry, but it should be two separate pages
    one: is the editor
    and the other: to be edited

  5. #5
    Join Date
    Jun 2008
    Location
    Europe
    Posts
    1,114
    If this solves your question, and it should, please click on "Thread Tools" and mark this thread [RESOLVED]


  6. #6
    Join Date
    Jun 2008
    Location
    Europe
    Posts
    1,114
    Then just break it into two parts (files).

    editor.html:
    HTML Code:
    <h2>Enter your text in the form</h2>
    <form name="form1" method="post" action="edited.php">
    <input type="text" name="something" size="36" /> &nbsp;&larr; Enter some short text here.<br />
    <textarea rows="3" cols="55" name="text"></textarea> &nbsp;&larr; Enter long text here.<br />
    <input type="submit" value="Go" />
    </form>

    edited.php:
    PHP Code:
    <div id="mydiv" name="mydiv">
    <?php

    $something 
    $_POST['something'];
    $text $_POST['text'];

    if(empty(
    $something) && empty($text)) {
    echo 
    'XXXXXXXXX - This is some text - XXXXXXXXXXXXX';
    } else {

    echo <<<EOD
    <b>$something</b><br /> $text
    EOD;

    }

    ?>
    </div>

  7. #7
    Join Date
    Jun 2008
    Location
    Europe
    Posts
    1,114

    Cool

    Those are your three solutions.

    8-)


    If you really want to make it interesting, you could send the result to an iframe:

    HTML Code:
    <h2>Enter your text in the form</h2>
    <form name="form1" method="post" action="edited.php" target="editedframe">
    <input type="text" name="something" size="36" /> &nbsp;&larr; Enter some short text here.<br />
    <textarea rows="3" cols="55" name="text"></textarea> &nbsp;&larr; Enter long text here.<br />
    <input type="submit" value="Go" />
    </form>
    <iframe src="edited.php" width="550" height="400" frameborder="0" scrolling="no" name="editedframe"></iframe>
    Last edited by donatello; 08-20-2012 at 06:12 AM.

  8. #8
    Join Date
    Aug 2012
    Posts
    5
    you're the master
    thanks a lot !!

    but still one little thing (i'm very very sorry, but i need this badly)

    i need the fourth solution which is the java script separate files.. and i wish that if write the codes in this forums and give me the files names..



    (i know i'm being a jerk, forgive me)

  9. #9
    Join Date
    Jun 2008
    Location
    Europe
    Posts
    1,114

  10. #10
    Join Date
    Aug 2012
    Posts
    5
    you continue to impress me, thanks
    RESLOVED

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



Recent Articles