Click here to Skip to main content
13,044,467 members (57,685 online)
Rate this:
Please Sign up or sign in to vote.
I have a jquery mobile app and I want to get an value from a hidden input field within a dynamically generated listview when selected and then pass the value to another page. How would I do that? How do I determine which listview item was clicked?

<ul data-role="listview" class="ui-listbox" data-theme="c"  role="listbox" style="margin-removed20px">
    <li data-role="list-divider" role="heading" tabindex="0" class="ui-li ui-li-divider ui-btn ui-bar-b ui-btn-up-undefined">Today's Journey</li>
    <?php foreach ($journeys as $journey) : ?>
    <?php if ($journey['user_type'] == 0): ?>
     //dynamically generated list
        <li class="list-item-speaker" data-icon="false">
            <a href="#journeydetails?id=<?php echo $journey['journey_id']; ?>" id="journeyDetailsDriver" data-transition="flip" >
                <div class="list-item-removed-speaker" style="float:left">
                    <img src="<?php echo $journey['facebook_image']; ?>" class="thumb-speaker-small" alt="<?php echo $journey['facebook_first_name']." ".$journey['facebook_last_name']; ?>" />
                    <h3 style="padding-removed10px;"><?php echo $journey['from_destination']." - ".$journey['to_destination']; ?></h3>
                    <p style="padding-removed10px"><?php echo $journey['facebook_first_name']." ".$journey['facebook_last_name']; ?></p>
                    <p style="padding-removed10px; padding-removed10px; font-size:0.9em; font-weight:bold"><?php echo $journey['depart_date']; ?></p>
                    //VALUE I NEED FROM HIDDEN FIELD
                    <input type="hidden" name="journeyID" id="journeyID" value="<?php echo $journey['journey_id']; ?>">
                <h3 style="float:right; margin-removed45px; color:#189ACB"><?php echo $journey['seats_available']. ' seats'; ?></h3>
Posted 25-Apr-13 7:07am
Updated 26-Apr-13 3:31am
sri senthil kumar 26-Apr-13 9:22am
May be you can use a session variable...
Shubhashish_Mandal 26-Apr-13 9:26am
or you can pass it as query string .
Colin Roe 26-Apr-13 9:30am
Thanks for the comments, but before I can pass data to another page, I need to determine which dynamically generated listview was selected so I can get the hidden value from within and I am unsure how to do this. Perhaps I should rephrase the question!
Shubhashish_Mandal 26-Apr-13 9:38am
When the list view is selected , put the selected value into the hidden filed.
Prasad Khandekar 26-Apr-13 10:33am
And how are you selecting the list item? What's the handler. Putting an id attribute on each list item will allow you to use JQuery selector's. Also try to use a different id for hidden field as well (something like journeyID_1, journeyID_2)
Colin Roe 26-Apr-13 10:39am
I don't have a handler, yet! Just trying to understand what I need to do first. Currently, each hidden field gets its own unique id through a counter and concatenating that to a string. I will now do the same for each listview item. Then I need to create a handler

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 26 Apr 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100