Jump to content

Recommended Posts

Hi

 

I'm reconfiguring a piece of code for a dropdown menu using the option tags. The dropdown is a simple 3 option dropdown. As it stands with the code below it always defaults to show the first option in the list. What I want is to be able to pre-select the option that shows (eg no 2 in the list). Normally of course with just option tags you use selected="selected" In this case though the code is a bit more complex and this coding is a bit beyond me. Any help would be appreciated.

 

<td> Membership Type

      </td>

      <td>

 

          <select name="type_chosen" size="1">

          {section name=types loop=$pid}

            <option value="{$pid[types]}" {$type_selected[types]}> {$type_name[types]}

            {if $type_price[types]}

                (${$type_price[types]})

            {/if}

 

            </option>

 

 

          {/section}

 

          </select>

Link to comment
https://forums.phpfreaks.com/topic/265523-option-dropdown/
Share on other sites

 

Here's the whole file. Does that help?

 

Unfortunately I'm not really a coder so please excuse my lack of knowledge in this area (still learning) - not familiar with smarty either...

 

 

 

 

 

{include file='../interface/html_register_header.php'}

 

<!-- CONTENT -->

 

 

 

 

 

 

 

 

<form action="{$SCRIPT_NAME}" Method=Post>

 

<table border="0" bordercolor="black" cellspacing="0" cellpadding="0" width="650" align="center">

  <tr>

  <td>

 

 

    {section name=users loop=$Error start=0 max=1}

 

    <fieldset>

    <legend><font color="red">Registration Errors</font> </legend>

    {/section}

 

    <p>

 

    {section name=sec1 loop=$Error}

    <font color="red">- {$Error[sec1]}</font><br>

    {/section}

 

    {section name=users loop=$Error start=0 max=1}

    </fieldset>

    {/section}

 

   

    <br>

 

    <fieldset>

 

    <legend><font color="#4169E1">Register New Account</font></legend>

 

    <p>

 

    <table border="0" cellspacing="3" cellpadding="4" width="100%">

    <tr>

      <td width="35%">Your Name</font></td>

      <td> <input type=text name="name" value="{$name}" size="35"></td>

    </tr>

 

    {if $request_username}

    <tr>

      <td>Username</font></td>

      <td> <input type=text name="username" value="{$username}" size="35"><br></td>

    </tr>

    {/if}

 

    <tr>

      <td>e-Mail Address</font></td>

      <td> <input type=text name="email" value="{$email}" size="35"><br></td>

    </tr>

    <tr>

      <td>Confirm e-Mail</font></td>

      <td> <input type=text name="cemail" value="{$cemail}" size="35"><br></td>

    </tr>

 

    <input type=hidden name="html" value="1" {$html_email_checked}>

 

    <tr>

 

      <td> Membership Type

      </td>

      <td>

 

          <select name="type_chosen" size="1">

          {section name=types loop=$pid}

            <option value="{$pid[types]}" {$type_selected[types]}> {$type_name[types]}

            {if $type_price[types]}

                (${$type_price[types]})

            {/if}

 

            </option>

 

 

          {/section}

 

          </select>

      </td>

    </tr>

 

    </table>

 

    </fieldset>

 

    <p>

 

    <fieldset>

    <!--<legend><font color="#4169E1">Addirional Account details</font></legend>-->

 

    <p>

 

    <table border="0" cellspacing="3" cellpadding="3" width="100%">

 

    {section name=customs loop=$fid}

 

    {if ($type[customs] == "checkbox") }

    <tr>

        <td width="35%" valign=top>{$question[customs]}</td>

        <td>{$answers[customs]}</td>

    </tr>

    {/if}

 

    {if ($type[customs] == "radio") }

    <tr>

        <td  width="35%" valign=top>{$question[customs]}</td>

        <td>{$answers[customs]}</td>

    </tr>

    {/if}

 

 

    {if ($type[customs] == "textarea") }

    <tr>

        <td  width="35%" valign=top>{$question[customs]}</td>

        <td>

          <textarea name="FIELD{$fid[customs]}" cols=33 rows=6>{$default_value[customs]}</textarea>

        </td>

    </tr>

 

    {/if}

    {if ($type[customs] == "dropdown") }

 

 

    <tr>

        <td  width="35%" valign=top>{$question[customs]}</td>

        <td>

          <SELECT name="FIELD{$fid[customs]}">

          {$answers[customs]}<br>

          </select>

      </td>

    </tr>

 

    {/if}

    {if ($type[customs] == "text") }

 

    <tr>

        <td  width="35%" valign=top>{$question[customs]}</td>

        <td>

        <input type="text" name="FIELD{$fid[customs]}" size="35" value="{$default_value[customs]}"></td>

    </tr>

       

    {/if}

 

    {/section}

 

  <tr>

    <td  colspan="2" align="right">

 

        <input type="submit" name="save_user" value="  Register  >> "> <br>

 

    </td>

  </tr>

 

  </table>

  </fieldset>

 

 

  </td>

  </tr>

 

</table>

 

 

  <!-- /CONTENT -->

 

 

<table border="0" height="70" width="100">

<tr>

<td>

</td>

</tr>

</table>

 

 

{include file='../interface/html_register_footer.php'}

 

 

Link to comment
https://forums.phpfreaks.com/topic/265523-option-dropdown/#findComment-1360824
Share on other sites

I've located two documents relating to smarty in a lib file. Would these be standard lib documents or do I need to post them?

 

I've also found another document called register.php, appended below, which I wonder if this is the one you mentioned.

 

Hope this is right for the tags

 


<?php

//////////////////////////////////////////////////////////////////

error_reporting(E_ALL ^ E_NOTICE);

//////////////////////////////////////////////////////////////////
// Strip HTML Code / Chars from User Input
//////////////////////////////////////////////////////////////////

while (list ($key,$val) = @each ($_GET)) { 

   if(!is_array($val)) {
      $_GET[$key] = htmlentities($val);
   }
}

while (list ($key,$val) = @each ($_POST)) { 

   if(!is_array($val)) {
      $_POST[$key] = strip_tags($val);

   }
}

/////////////////////////////////////////////////////////////////
// Define & Get Admin Settings:
/////////////////////////////////////////////////////////////////

define( 'CFG_LIB_PATH', 'libs/' );
define( 'CFG_PATH', 	'configs/' );

require_once(CFG_PATH       . "config.php");
require_once(CFG_PATH       . "admin_config.php");
require_once(CFG_LIB_PATH   . "Smarty.class.php");
require_once(CFG_LIB_PATH   . "class.phpmailer.php");
require_once(CFG_LIB_PATH   . "class.dbsession.php");

/////////////////////////////////////////////////////////////////
// Etc...
/////////////////////////////////////////////////////////////////

$conn = mysql_connect(CFG_db_host,CFG_db_username,CFG_db_password) or die ('Error connecting to mysql');
$db = @mysql_select_db(CFG_db_name, $conn) or die(mysql_error());


/////////////////////////////////////////////////////////////////
// Set Session Support
/////////////////////////////////////////////////////////////////

$sessions_in_db = CFG_Sessions_In_DB;

if($sessions_in_db) {
   $session = new dbsession();
}

else { 
   session_start();
}
/////////////////////////////////////////////////////////////////

$query = "select * FROM mm_settings"; 
$result = mysql_query($query); 

while ($data = @mysql_fetch_array ($result))  { 
   $settings[$data[name]] = $data[setting];
} 


/////////////////////////////////////////////////////////////////
// Remove Remember Me Cookies:
/////////////////////////////////////////////////////////////////

if($_POST[email]) {

   setcookie("email_address","$_POST[email]",time()+$settings[remember],"/","",0); 
   setcookie("pass","0",time()+$settings[remember],"/","",0); 

}



/////////////////////////////////////////////////////////////////
// Get Functions:
/////////////////////////////////////////////////////////////////

require_once(CFG_LIB_PATH   . "user_functions.php");
require_once(CFG_LIB_PATH   . "user_add_functions.php");
require_once(CFG_LIB_PATH   . "admin_functions.php");


$smarty = new Smarty;

$todays_date = date("Y-m-d"); 
if($todays_date != "$settings[cycle_last_ran]") {
   daily_cycle();
}



//////////////////////////////////////////////////////////////////
// Subscribe / Add e-Mail
//////////////////////////////////////////////////////////////////

add_user();


exit;


?>

18646_.php

Link to comment
https://forums.phpfreaks.com/topic/265523-option-dropdown/#findComment-1360914
Share on other sites

Look through your .php files, not config files but the processing code, for something that has $type_selected or $types, and is not a smarty .tpl

 

It might be in the add_user() function. You don't have enough code here to work with. You will probably need to hire someone to help you since this is not your code, and you don't understand it.

Link to comment
https://forums.phpfreaks.com/topic/265523-option-dropdown/#findComment-1361049
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.