Click here to Skip to main content
15,893,401 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a list item which is Executive Room, when i click that list, I call the myFunction('tabExe') method with a parameter "tabExe", In my console, it prints the value "tabExe", does it populate the variable successfully ? and I have a textarea below the list item, how to print the value in the textarea using php? please help... tnx

//HTML

HTML
<ul><li><a name="tabExe" önclick="myFunction('tabExe');" id="tabExe" href="#Exec">Executive Room</a></li></ul>


//JavaScript

JavaScript
function myFunction(str){

    var val = str;
    alert(val);
    $.ajax({
    type: 'POST',
    url: 'ROOMS.php',
    data: {
        source1 : val,
        },
    success: function( data ) {
        console.log( data );
        }
    });
}


[edit]SHOUTING removed, Code blocks added - OriginalGriff[/edit]
Posted
Updated 12-Sep-14 22:55pm
v2
Comments
OriginalGriff 13-Sep-14 4:56am    
DON'T SHOUT. Using all capitals is considered shouting on the internet, and rude (using all lower case is considered childish). Use proper capitalization if you want to be taken seriously.

1 solution

Yes it populates your php variable successfully and returns the value in the variable 'data' used in the javascript below

HTML
<html>
<head>
<script type="text/javascript" src="jquery/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
function myFunction(str){
 
    var val = str;
    alert(val);
    $.ajax({
    type: 'POST',
    url: 'ROOMS.php',
    data: {
        source1 : val,
        },
    success: function( data ) {
        //console.log( data );
		$('#testTextArea').val(data);
        }
    });
}

</script>

<ul><li><a name="tabExe" onclick="myFunction('tabExe');" id="tabExe" href="javascript:void(0)">Executive Room</a></li></ul>
<textarea id="testTextArea"></textarea>
</body>
</html>
 
Share this answer
 

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