Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Mar 2007
    Posts
    91
    Thanks
    2
    Thanked 0 Times in 0 Posts

    [Easy] What is the right code for join this 2 textfield

    I have 2 textfield (for search Name and Username) and i want to joining them to just one textfield only, so people can search for Name and Username in just one field


    this is textfield for Name
    <input type="text" name="firstname" size="50" value="<?= $this->get('firstname') ?>" />



    and this textfield for Username
    <input type="text" name="username" size="50" value="<?= $this->get('username') ?>" />







    what is the right code to do that?

    i try this, but it is not right
    <input type="text" name="firstname" size="50" value="<?= $this->get('firstname') ?> <?= $this->get('username') ?>" />

  • #2
    Regular Coder ArcticFox's Avatar
    Join Date
    Jan 2004
    Location
    Vostok Station, AQ
    Posts
    602
    Thanks
    35
    Thanked 3 Times in 3 Posts
    Let's see the rest of your code.
    <div> - putting your mind in a box since 1997

  • #3
    New Coder
    Join Date
    Mar 2007
    Posts
    91
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Ah ok this is all the code, thanks for answering


    <?php
    $this->_header->title = L('search profiles');
    ?>
    <?= $this->_header->header() ?>
    <div align="center">
    <?= $this->_navbar->navbar() ?>
    </div>
    <br />
    <?= $this->display_notices() ?>
    <div id="container" style="width:569px;font-size:12px">
    <?php
    if ($this->get('show results'))
    {
    $count = $this->get('count');
    ?>
    <img src="images/search_results.png" alt="<?= L('search results')?>"><div id="s_res" style="border:1px solid #68893b; background-color:#e9efe5">
    <style type="text/css">
    #s_res a {text-decoration: none}
    #s_res {color: #000}
    input {border:1px solid #4e5d77; background-color:#fff;}
    li {padding:3px}
    </style>
    <?php

    if ($count >= 250)
    {
    echo '<div align="center"><strong>' . L('search returned too many results', 250) . '</strong>
    </div><br />';
    }

    if ($this->get('pages') == 0)
    {
    echo L('no users found');
    }
    else
    {
    #
    # Pages
    #
    if ($this->get('pages') > 1)
    {
    $urlsearch = 'searchid=' . $this->get('searchid');

    echo '<div align="center">';
    if ($this->get('page') > 1)
    {
    for ($i = 1; $i < $this->get('page'); $i++)
    {
    echo " <a href=\"search.php?$urlsearch&amp;page=$i\">". $i ."</a> ";
    }
    }

    echo "<strong>[" . $this->get('page') . "]</strong>";

    if ($this->get('page') < $this->get('pages'))
    {
    for ($i = $this->get('page') + 1; $i <= $this->get('pages'); $i++)
    {
    echo " <a href=\"search.php?$urlsearch&amp;page=$i\">" . $i . "</a> ";
    }
    }
    echo '</div>';
    }
    $count = 0;
    echo "<table width=\"100%\"><tr><td width=\"50%\" valign=\"top\"><ol start=\"" . $this->get('start') . "\">\n";
    foreach ($this->get('users') as $user)
    {
    echo "<li><a href=\"" . $this->_zoints->profile_url($user) . "\">$user[username]</a></li>\n";
    $count ++;
    if($count == 13) {
    echo '</ol></td><td width="50%" valign="top"><ol start="' . ($this->get('start')+13) . '">';
    }
    }
    echo "</ol></td></tr></table>\n";
    }
    ?>
    </div><br />
    <?php
    }
    ?>

    <div style="background:url(images/search_profiles.png); height:57px; margin:0px auto">&nbsp;</div>
    <div class="blu_rc_cntr_480" style="width:569px;background-color:#d4dae4;">
    <div class="blu_rc_t">
    <div class="blu_rc_b">
    <div class="blu_rc_l">
    <div class="blu_rc_r">
    <div class="blu_rc_bl">
    <div class="blu_rc_br">
    <div>
    <div>
    <div class="blu_rc_content" style="color:#000">
    <script type="text/javascript" language="javascript">
    <!--
    function clear_form()
    {
    for (var i = 0; i < document.search.elements.length; i++)
    {
    var element = document.search.elements[i];
    if (element.type == "radio")
    {
    if (element.value == "0")
    {
    element.checked = true;
    }
    }
    else if (element.type == "checkbox")
    {
    element.checked = false;
    }
    else if (element.type == "text")
    {
    element.value = "";
    }
    else if (element.name == "country" || element.name == "state" || element.name == "relationship")
    {
    element.value = "";
    }
    }
    }
    -->
    </script>

    <form action="<?= $this->_zoints->_config['site url'] ?>search.php" method="post" name="search">
    <?= $this->get_hidden() ?>
    <table width="100%">
    <tr>
    <td colspan="2" align="center"><p>Cari Profile Dengan... </p>
    <p>&nbsp;</p></td>
    </tr>
    <tr>
    <td align="right">Nama</td>
    <td align="left"><input type="text" name="firstname" size="50" value="<?= $this->get('firstname') ?>" />
    </td>
    </tr>
    <tr>
    <td align="right"><?= L('username')?></td>
    <td align="left"><input type="text" name="username" size="50" value="<?= $this->get('username') ?>" /></td>
    </tr>
    <tr>
    <td align="right"><?= L('gender')?></td>
    <td align="left"><input type="radio" name="gender" value="m" <?= $this->is_checked('gender', 'm') ?> />
    <?= L('male')?>
    <input type="radio" name="gender" value="f" <?= $this->is_checked('gender', 'f') ?> />
    <?= L('female')?>
    <input type="radio" name="gender" value="0" <?= $this->is_checked('gender', '0') ?> />
    <?= L('either')?>
    </td>
    </tr>
    <tr>
    <td align="right"><?= L('relationship status')?></td>
    <td align="left"><?= $this->generate_select('relationship', $this->_zoints->_relationship, $this->get('relationship'), true) ?></td>
    </tr>
    <tr>
    <td align="right">&nbsp;</td>
    <td align="left">&nbsp;</td>
    </tr>
    <tr>
    <td align="right"><?= L('age')?></td>
    <td align="left" valign="center">
    <input type="text" name="agelower" size="4" value="<?= $this->get('agelower') ?>" /> <?= L('-to-')?>
    <input type="text" name="ageupper" size="4" value="<?= $this->get('ageupper') ?>" />
    </td>
    </tr>
    <tr>
    <td align="right">Location</td>
    <td align="left"><input type="text" name="city" size="50" value="<?= $this->get('city') ?>" /></td>
    </tr>
    <tr>
    <td align="right">Kode Pos </td>
    <td align="left"><input type="text" name="zip" size="6" value="<?= $this->get('zip') ?>" /></td>
    </tr>
    <tr>
    <td align="right"><?= L('job')?></td>
    <td align="left"><input type="text" name="job" size="50" value="<?= $this->get('job') ?>" /></td>
    </tr>
    <tr>
    <td align="right"><?= L('school')?></td>
    <td align="left"><input type="text" name="school" size="50" value="<?= $this->get('school') ?>" /></td>
    </tr>
    <tr>
    <td align="right">&nbsp;</td>
    <td align="left">
    <input type="radio" name="s_status" value="1" <?= $this->is_checked('s_status', 1) ?> /> <?=__('Sekolah/Kuliah')?>
    <input type="radio" name="s_status" value="2" <?= $this->is_checked('s_status', 2) ?> /> <?=__('Kerja')?>
    <input type="radio" name="s_status" value="0" <?= $this->is_checked('s_status', 0) ?> /> <?=__('Semua')?>
    </td>
    </tr>
    <tr>
    <td align="right">&nbsp;</td>
    <td align="left">&nbsp;</td>
    </tr>
    <tr>
    <td align="right">Kata Kunci </td>
    <td align="left"><input type="text" name="keywords" size="50" value="<?= $this->get('keywords') ?>" /></td>
    </tr>
    <tr>
    <td align="center" colspan="2">
    <button type="submit"><?= L('search')?></button>
    </td>
    </tr>
    </table>
    </form>
    </div>
    </div>
    </div>
    </div>
    </div>
    </div>
    </div>
    </div>
    </div>
    </div>
    </div>

    <?= $this->footer(); ?>

  • #4
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    PHP Code:
    <input type="text" name="firstname" size="50" value="<?php echo $this->get('firstname').' '.$this->get('username'?>" />

  • #5
    New Coder
    Join Date
    Mar 2007
    Posts
    91
    Thanks
    2
    Thanked 0 Times in 0 Posts
    hmmm that code not working too, fyuhh so this is little difficult to do, i will try some combination again

    let me know if you have idea why this is not working


    this forum is very good, i just know forum like this, i will visiting here more often

  • #6
    New to the CF scene
    Join Date
    Mar 2007
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hey,

    you are using $this outside a class? Or is this file included into a class, or something?
    However, if <?=$this->get("username")?> returns a value and also <?=$this->get("firstname")?> does, than you could combine theese two strings like:

    PHP Code:
    <?=$this->get("username") . " " $this->get("firstname")?>
    Nightfire's example should work tho.
    So I guess, that the method "get" of your object, just doesnt return anything


  •  

    Posting Permissions

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