Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
4.00/5 (1 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?

PHP
<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']; ?>">
                </div>
                <h3 style="float:right; margin-removed45px; color:#189ACB"><?php echo $journey['seats_available']. ' seats'; ?></h3>
            </a>
        </li>
</ul>
Posted
Updated 26-Apr-13 3:31am
v3
Comments
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)

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900