Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

dynamic list/menu with more that one value

Engaged ,
Oct 28, 2011 Oct 28, 2011

i am trying to create a dynamic list / menu but pull more that one vlaue from the database. any ideas how this can be done, also once the user has selected the value they want, i want that to populate another area on the site?

thanks in advance

jon

TOPICS
Server side applications
1.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 28, 2011 Oct 28, 2011

i am trying to create a dynamic list / menu but pull more that one vlaue from the database.

I don't understand what this means - can you say more about "pull more than one value" in the context of this question?

once the user has selected the value they want, i want that to populate another area on the site?

That's pretty simple to do with javascript, e.g,

<select name="foo" onchange="document.getElementById('bar').value=this.value">

On change, that javascript would populate another field with the ID of "bar", with the changed value of the <select> tag.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 28, 2011 Oct 28, 2011

ok let me explain, when i use the create dynamic menu / list, i select the RecordSet then it give me the option to select the value from the recordset, this comes from the database, what if i want more information from another table within the database to be diplayed?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 28, 2011 Oct 28, 2011

Can you give an example?  I still am not grasping what you want.  Are you wanting this information to be displayed within the select tag? Like -

Option1 from table1

...

Option12 from table1

Option13 from table2

...

Option22 from table 2

Like that?

Or like -

Option 1 from table 1 and Option 1 from table 2

Option 2 from table 1 and Option 2 from table 2

...

Like that?

See, the more specific information you give us in your first post, the sooner you will get a reasonable answer....

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 28, 2011 Oct 28, 2011

sorry, will try and explain more clear

table has example: userid, address1, address two

on the menu on each line of the drop down i want to diplay the userid, address1, address two rather than just the lets say userid

i hope this is clearer

i do apologise

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 28, 2011 Oct 28, 2011

Yes, that's more clear.

There would be no way to do this kind of thing with DW's standard UI-type code. You would have to manually add the capability to insert the additional information to that already written by DW.  For example, I happen to be writing a page with a select field that is populated from a recordset called 'rsSupCode':

  <select name="supCode" id="supCode">

  <option> >> Select Supplier << </option>

    <?php

          do { 

     ?>

    <option value="<?php echo $row_rsSupCode['supCode']; ?>"><?php echo $row_rsSupCode['supCode']?></option>

    <?php

} while ($row_rsSupCode = mysql_fetch_assoc($rsSupCode));

?>

  </select>

This is how DW writes those dynamic values when you use the UI.  Let's say that recordset also contains fields for username and userlocation, and I wanted to add them to the list, I could do this -

    <option value="<?php echo $row_rsSupCode['supCode']; ?>"><?php echo $row_rsSupCode['supCode'] . " " . $row_rsSupCode['username'] . " " . $row_rsSupCode['userlocation']; ?></option>

That would only add those items to the visible part of the option, not to the value as well.

Make sense?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 28, 2011 Oct 28, 2011

ok so manually put them in, when you say "That would only add those items to the visible part of the option, not to the value as well." what does that mean? that the information will be read only, as it only needs to be read only as the id will contain all the relevent information to pass.

makes sense i think, will give it a go then

thanks for you help

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 28, 2011 Oct 28, 2011

I think you have it....

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 28, 2011 Oct 28, 2011

well i tried that, i wanted to add the field prop_add1.

<?php

do { 

?>

                        <option value="<?php echo $row_rsApplyNow['prop_id']."".$row_rsApplyNow['prop_add1'];?>"><?php echo $row_rsApplyNow['prop_id']?></option>

                        <?php

} while ($row_rsApplyNow = mysql_fetch_assoc($rsApplyNow));

  $rows = mysql_num_rows($rsApplyNow);

  if($rows > 0) {

      mysql_data_seek($rsApplyNow, 0);

            $row_rsApplyNow = mysql_fetch_assoc($rsApplyNow);

  }

?>

so the list will show the following

propid, prop_add1

all it done was gave me the prop id's

cheers

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 28, 2011 Oct 28, 2011

all it done was gave me the prop id's

Did you look at the live code?  The VALUE attribute of the <option> tag would have both the prop_id and the prop_add1 as values.  More than likely you wanted to reverse this -

<option value="<?php echo $row_rsApplyNow['prop_id'];?>"><?php echo $row_rsApplyNow['prop_id'] . " " . $row_rsApplyNow['prop_add1']; ?></option>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 28, 2011 Oct 28, 2011

thats seems to have worked thanks for you help, and to populate another field with this information on the same page when i click it i use the javascript from previous, yes??

thanks

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 28, 2011 Oct 28, 2011
LATEST

Yeah - should work fine.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines