Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Javascript PHP jQuery
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']; ?>">
                </div>
                <h3 style="float:right; margin-removed45px; color:#189ACB"><?php echo $journey['seats_available']. ' seats'; ?></h3>
            </a>
        </li>
</ul>
Posted 25-Apr-13 8:07am
Edited 26-Apr-13 4:31am
v3
Comments
sri senthil kumar at 26-Apr-13 9:22am
   
May be you can use a session variable...
Shubhashish_Mandal at 26-Apr-13 9:26am
   
or you can pass it as query string .
Colin Roe at 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 at 26-Apr-13 9:38am
   
When the list view is selected , put the selected value into the hidden filed.
Prasad Khandekar at 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 at 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)



Advertise | Privacy | Mobile
Web04 | 2.8.1411023.1 | Last Updated 26 Apr 2013
Copyright © CodeProject, 1999-2014
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