Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Question

code block edit
Source Link

When I press on any of the ‘region’ names in the list ('href''href' links), the matching list of 'cities' is showing underneath.

;
;
<?php while(has_list_regions()) { ?>
 <a href="javascript:show_region('<?php echo list_region_id() ?>');"></a>
<?php } ?>
<script type="text/javascript">
 function show_region(chosen_region_id) 
 {
 ; 
 $(this).slideDown(200);
 ;
 <?PHP $clicked_tag = 'chosen_region_id'; ?>
 }
</script>

Is it possible to include PHP code within a section of JavaScript? Because I need to get the ID of the selected ‘href’href that I clicked. I am trying to include the PHP code in the above JavaScript function but it doesn’t work.

When I press on any of the ‘region’ names in the list ('href' links), the matching list of 'cities' is showing underneath.

;
;
<?php while(has_list_regions()) { ?>
 <a href="javascript:show_region('<?php echo list_region_id() ?>');"></a>
<?php } ?>
<script type="text/javascript">
 function show_region(chosen_region_id) 
 {
 ; 
 $(this).slideDown(200);
 ;
 <?PHP $clicked_tag = 'chosen_region_id'; ?>
 }
</script>

Is it possible to include PHP code within a section of JavaScript? Because I need to get the ID of the selected ‘href’ that I clicked. I am trying to include the PHP code in the above JavaScript function but it doesn’t work.

When I press on any of the ‘region’ names in the list ('href' links), the matching list of 'cities' is showing underneath.

<?php while(has_list_regions()) { ?>
 <a href="javascript:show_region('<?php echo list_region_id() ?>');"></a>
<?php } ?>
<script type="text/javascript">
 function show_region(chosen_region_id) 
 {
 ; 
 $(this).slideDown(200);
 ;
 <?PHP $clicked_tag = 'chosen_region_id'; ?>
 }
</script>

Is it possible to include PHP code within a section of JavaScript? Because I need to get the ID of the selected href that I clicked. I am trying to include the PHP code in the above JavaScript function but it doesn’t work.

Source Link
blsn
  • 1.1k
  • 3
  • 18
  • 41

PHP code in JavaScript to get variable

When I press on any of the ‘region’ names in the list ('href' links), the matching list of 'cities' is showing underneath.

;
;
<?php while(has_list_regions()) { ?>
 <a href="javascript:show_region('<?php echo list_region_id() ?>');"></a>
<?php } ?>
<script type="text/javascript">
 function show_region(chosen_region_id) 
 {
 ; 
 $(this).slideDown(200);
 ;
 <?PHP $clicked_tag = 'chosen_region_id'; ?>
 }
</script>

Is it possible to include PHP code within a section of JavaScript? Because I need to get the ID of the selected ‘href’ that I clicked. I am trying to include the PHP code in the above JavaScript function but it doesn’t work.

default

AltStyle によって変換されたページ (->オリジナル) /