PostNuke: A Flexible Open Source Content Management System
home | forum | international support | contact us

Support Forum

Start ::  Developers Corner ::  Module Development ::  Problem retrieving HTML variables

Moderated by: Support Team

Bottom
Problem retrieving HTML variables

  • Link to this postingPosted: 07.04.2008, 15:01
    Profile
    DJUS
    rank:
    pnFreshman pnFreshman
    registered:
     March 2008
    Status:
    offline
    last visit:
    29.04.08
    Posts:
    15
    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
  • Link to this postingPosted: 08.04.2008, 10:44
    Profile Homepage
    rgasch
    rank:
    Steering Committee Steering Committee
    registered:
     January 2003
    Status:
    offline
    last visit:
    01.05.08
    Posts:
    550
    Looking at your select list code, your call to FormUtil::getPassedValue() should use "liste3" as the first parameter ...

    Greetings
    R
  • Link to this postingPosted: 08.04.2008, 16:02
    Profile
    DJUS
    rank:
    pnFreshman pnFreshman
    registered:
     March 2008
    Status:
    offline
    last visit:
    29.04.08
    Posts:
    15
    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
  • Link to this postingPosted: 08.04.2008, 16:13
    Profile Homepage
    rgasch
    rank:
    Steering Committee Steering Committee
    registered:
     January 2003
    Status:
    offline
    last visit:
    01.05.08
    Posts:
    550
    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
  • Link to this postingPosted: 08.04.2008, 17:18
    Profile
    DJUS
    rank:
    pnFreshman pnFreshman
    registered:
     March 2008
    Status:
    offline
    last visit:
    29.04.08
    Posts:
    15
    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
  • Link to this postingPosted: 09.04.2008, 13:50
    Profile
    DJUS
    rank:
    pnFreshman pnFreshman
    registered:
     March 2008
    Status:
    offline
    last visit:
    29.04.08
    Posts:
    15
    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
  • Link to this postingPosted: 09.04.2008, 15:26
    Profile Homepage
    rgasch
    rank:
    Steering Committee Steering Committee
    registered:
     January 2003
    Status:
    offline
    last visit:
    01.05.08
    Posts:
    550
    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
  • Link to this postingPosted: 09.04.2008, 17:39
    Profile
    DJUS
    rank:
    pnFreshman pnFreshman
    registered:
     March 2008
    Status:
    offline
    last visit:
    29.04.08
    Posts:
    15
    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
  • Link to this postingPosted: 10.04.2008, 10:00
    Profile Homepage
    rgasch
    rank:
    Steering Committee Steering Committee
    registered:
     January 2003
    Status:
    offline
    last visit:
    01.05.08
    Posts:
    550
    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
  • Link to this postingPosted: 10.04.2008, 11:16
    Profile
    DJUS
    rank:
    pnFreshman pnFreshman
    registered:
     March 2008
    Status:
    offline
    last visit:
    29.04.08
    Posts:
    15
    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
  • Link to this postingPosted: 10.04.2008, 11:19
    Profile Homepage
    markwest
    rank:
    Moderator Moderator
    registered:
     March 2002
    Status:
    offline
    last visit:
    24.04.08
    Posts:
    7647
    You must use code tags to post code here - see the 'select code type' drop down for specific code formatting types.

    -Mark
  • Link to this postingPosted: 10.04.2008, 12:10
    Profile
    DJUS
    rank:
    pnFreshman pnFreshman
    registered:
     March 2008
    Status:
    offline
    last visit:
    29.04.08
    Posts:
    15
    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
  • Link to this postingPosted: 10.04.2008, 13:40
    Profile
    Topiatic
    rank:
    pnProfessional pnProfessional
    registered:
     November 2003
    Status:
    offline
    last visit:
    09.05.08
    Posts:
    1530
    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>

    -----
    viewTopiaryWorks($twWorks, $twRosterMaster)
  • Link to this postingPosted: 10.04.2008, 13:49
    Profile
    DJUS
    rank:
    pnFreshman pnFreshman
    registered:
     March 2008
    Status:
    offline
    last visit:
    29.04.08
    Posts:
    15
    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

Start ::  Developers Corner ::  Module Development ::  Problem retrieving HTML variables

Main Menu

Extensions Database

Documentation

Development

Login





 


 Log in Problems?
 New User? Sign Up!

Donate to PostNuke