Populating text field with ID's

hi i have created a favourites button using.append to store users response which is displayed onto the favourites page. I am trying to now use the same id’s to store these responses in a textfield and mailto a email preferablly using a button of somesort.

 <!-- This is page 1-->
    <div data-role="page" id="item1">
     
      <div data-role="header" data-position="fixed"> <!-- header-->
        <h1>Item 1</h1>
      </div>
      
      <div role="main" class="ui-content"> <!-- main contain-->
      
      	<!-- buttons allowing navigation to item 1 and favourites pages-->
          <a href="#item2" class="ui-btn ui-btn-inline">Item 2 page</a>
          <a href="#favourites" class="ui-btn ui-btn-inline">Favourites page</a>
          
          <p>Here is all the details for item 1</p>

         <!-- favourites button-->
          <fieldset data-role="controlgroup" data-type="horizontal">
              <input type="checkbox" name="favourite1" id="favourite1" class="custom">
              <label for="favourite1"><span class="ui-icon-star ui-btn-icon-left">Add to favourites</span></label>
			  <div id="dog"><img id="theImg"  src="images/dog.png" />Where is the image?</div>
           </fieldset>
      
      </div> <!-- end main contain--> 
	 
     
   <!-- This is page 2-->
    <div data-role="page" id="item2">
     
      <div data-role="header" data-position="fixed"> <!-- header-->
        <h1>Item 2</h1>
      </div>
      
      <div role="main" class="ui-content"> <!-- main contain-->
      
      	<!-- buttons allowing navigation to item 2 and favourites pages-->
          <a href="#item1" class="ui-btn ui-btn-inline">Item 1 page</a>
          <a href="#favourites" class="ui-btn ui-btn-inline">Favourites page</a>
		 

          
          <p>Here is all the details for item 1</p>

         <!-- favourites button-->
          <fieldset data-role="controlgroup" data-type="horizontal">
              <input type="checkbox" name="favourite2" id="favourite2" class="custom">
              <label for="favourite2"><span class="ui-icon-star ui-btn-icon-left">Add to favourites</span></label>
           </fieldset>
      
      </div> <!-- end main contain-->

<!-- Favourites page -->
    <div data-role="page" id="favourites">
     
      <div data-role="header" data-position="fixed"> <!-- header-->
        <h1>Favourites</h1>
      </div>
      
      <div role="main" class="ui-content"> <!-- main contain-->
      
       <h1>Favourites</h1>
      
      	<!-- buttons allowing navigation to item 1 and item 2-->
          <a href="#item1" class="ui-btn ui-btn-inline">Item 1 page</a>
          <a href="#item2" class="ui-btn ui-btn-inline">Item 2 page</a>
          
          <div id="favourite-content"><p>My favourites: </p></div>
		  
		<div id="list"
		<form action="mailto:moksuhd.khan@gmail.com Feedback" method="post" enctype="text/plain">
			Email Adress:<br />
		<input type="text" id ="fav" name="email_address" value="" maxlength="100" /><br />

		<input type="submit" value="Submit" />

		</form>
		</div> 
			
      </div> <!-- end main contain-->

<


<script>
	 $(document).on( 'pagecontainerbeforehide', 'body', function( event, ui){
	   //do something
	   if ( ui.nextPage.attr('id')== "favourites") {
		   $("#favourite-content").html ("");
		    if ($( "#favourite1" ).is( ":checked" )) {
				$("#favourite-content").prepend('<img id="theImg"  src="images/dog.png"/>');
			}
			 if ($( "#favourite2" ).is( ":checked" )) {
				$("#favourite-content").append("<p>item2 details</p>");
			}
		   
		  }
	   
	   });
	 
     </script>
<script>
$(document).ready(function(){
if( ('id')=="fav"){
$("#favourite-content").show();
</script>

});

There is a stray < above the opening script tag. Is that just an error in copying the code to the forum?

There is also a closing </script> tag inside the JS, and the markup is not well-formed altogether… @moksuhdkhan could you post a working example that we can run to see what you have so far, including the libraries you are using? A codepen would be ideal. :-)

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.