Problem retrieving HTML variables  Top

  • Hello !
    I am using a combobox in a HTML pages. The combo is filled dynamically with values from database.
    When i am reading those variables i can find only the first word of the sentence.

    here is what i have done :
    (HTML)
    // HTML code to show the whole list of a product

    <*select name="liste3" id="liste3">
    <*option value="">BAIE
    <*!--[foreach from=$id_baie item=iden]-->
    <*option value=>
    <*!--[/foreach]-->
    <*/select>

    (PHP)
    $mac = FormUtil::getPassedValue('liste_macro',isset($args['liste_macro']) ? $args['liste_macro'] : null, 'REQUEST');

    P.S : $mac variable is filled with the first word of the combo sentence

    Do you have any idea about the problem ? thx




    edited by: DJUS, Apr 07, 2008 - 03:06 PM
  • Looking at your select list code, your call to FormUtil::getPassedValue() should use "liste3" as the first parameter ...

    Greetings
    R
  • I am sorry i made a copy paste error when i was writting this message ! you are right rgash i was using liste_macro not liste3!

    <*select name="liste_macro" id="liste_macro">
    <*option value="">
    <*!--[foreach from=$macro item=mac]-->
    <*option value=>
    <*!--[/foreach]-->
    <*/select>

    (PHP)
    $mac = FormUtil::getPassedValue('liste_macro',isset($args['liste_macro']) ? $args['liste_macro'] : null, 'REQUEST');

    Always the same problem icon_confused
    Greetings




    edited by: DJUS, Apr 08, 2008 - 04:05 PM
  • Are you sure you have this selector in a "form" tag?

    Otherwise, in your code where you have your FormUtil::getPassedValue() call, place the following line:

    prayer ($_REQUEST);

    This will show you what's in $_REQUEST (ie: what has been posted). If you don't see any output, place an "exit()" call after the prayer() call ... this is sometimes required when you immideately redirect ...

    Greetings
    R
  • I use a form for my selector. And i palced a prayer ($_REQUEST) which showed me the value of each variable, liste_macro too : (string) liste_macro = Pouvoir

    While what i selected in my combo box for example was the following sentence : Pouvoir separateur en atténuation

    thanx for your help rgash!

    Greetings
  • I still can't find why i have only the first word of the sentence. I need the whole sentence in order to carry on!

    help me please!
    Greetings
  • Could it be that you didn't enclose your value in quotes? Take a look at your HTML source code in order to verify this ...

    Greetings
    R
  • I don't think so, anyway i took a look at my HTML code and i couldn't find any error!
    here is my form:

    <*form class="numuserdate" action="" method="post" *enctype="application/x-www-form-urlencoded">
    <*input type="text" name="macro_val" id="macro_val" value=""/>
    <*input type="text" name="macro_ns" id="macro_ns" value=""/>
    <*select name="liste_macro" id="liste_macro">
    <*!--[foreach from=$macro item=mac]-->
    <*option value=>
    <*!--[/foreach]-->
    <*/select>

    Greetings











    edited by: DJUS, Apr 09, 2008 - 05:41 PM
  • Unfortunately, your select tag code above is incomplete, so I can't quite tell you what the issue is. Fact is, FormUtil is used extensively throughout PN and we've never seen a failure that couldn't be explained by a user/developer coding error.

    Please post your complete HTML code for further analysis ...

    Greetings
    R
  • Ok! I am sorry i should have post the whole code from the beginning !
    Here is my code HTML:

    <*form class="numuserdate" action=""
    *method="post" enctype="application/x-www-form-urlencoded">
    <*input type="text" name="macro_val" id="macro_val" value=""/>
    <*input type="text" name="macro_ns" id="macro_ns" value=""/>
    <*select name="liste_macro" id="liste_macro">
    <*!--[foreach from=$macro item=mac]-->
    <*option value=>
    <*!--[/foreach]-->
    <*/select>
    <*input name="submit" type="submit" value="OK" />
    <*input type="text" name="affich_macro" id="affich_macro" value=""/>
    <*/form>

    My PHP code :

    $mac = FormUtil::getPassedValue('liste_macro',isset($args['liste_macro']) ? $args['liste_macro'] : null, 'REQUEST');

    Greetings




    edited by: DJUS, Apr 10, 2008 - 11:22 AM
  • You must use code tags to post code here - see the 'select code type' drop down for specific code formatting types.

    -Mark

    --
    Visit My homepage and Zikula themes.
  • Here it is :

    Code

    <form class="numuserdate" action="<!--[pnmodurl modname="num" type="user" func="macro"]-->" method="post"enctype="application/x-www-form-urlencoded">
    <input type="text" name="macro_val" id="macro_val" value="<!--[$type]-->"/> 
    <input type="text" name="macro_ns" id="macro_ns" value="<!--[$num_serie]-->"/> 
    <select name="liste_macro" id="liste_macro">    
    <!--[foreach from=$macro item=mac]-->   
    <option value=<!--[$mac.lib]-->><!--[$mac.lib]--></option>
    <!--[/foreach]-->
    </select>      
    <input name="submit" type="submit" value="OK" />
    <input type="text" name="affich_macro" id="affich_macro" value="<!--[$i_mac]-->"/>     
    </form>

    My PHP code :

    Code

    $mac = FormUtil::getPassedValue('liste_macro',isset($args['liste_macro']) ? $args['liste_macro'] : null, 'REQUEST');

    Greetings



    edited by: DJUS, Apr 10, 2008 - 12:10 PM
  • The value of your option element needs to be double quoted, without them the parser stops reading at the first white space it gets to... hence you only getting the first word. All HTML name value pairs need to be double quoted as a matter of standards. Should look like this:

    Code

    <option value="<!--[$mac.lib]-->"><!--[$mac.lib]--></option>


    --
    Under Construction!
  • thanks everybody ! That was my problem !
    I used the option value many times in my code without having to extract sentences with white space and it worked! That's why i haven't thought that it was the problem!

    thanks again! icon_smile

This list is based on the users active over the last 60 minutes.