Link to home
Start Free TrialLog in
Avatar of doctorbill
doctorbillFlag for United Kingdom of Great Britain and Northern Ireland

asked on

php and java

I have the following code on my php page:

</php

$anchor = $_POST[''varname2'];
?>

<script type="text/javascript">
      function GoBackTo($anchor)
      {
            form1.action = 'orders_find_visit_print_custom_status_noforms_nocosts_idfilter2.php#' + $anchor;
            form1.submit()
      }
</script>

What I am trying to do is to use a hidden field value (varname2), passed to the page on form submission, as an anchor name in a javascript.  I am not sure if this is the way to pass the php variable to the javascript
ASKER CERTIFIED SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of doctorbill

ASKER

Here is the working code so far:
--------------------------------------
<script type="text/javascript">
      function GoBackTo(anchor3)
      {
            form1.action = 'orders_find_visit_print_custom_status_noforms_nocosts_idfilter2.php#' + anchor3;
            form1.submit()
      }
</script>

Problem: The "anchor3" is the name of an anchor which is being incremented down the page in a php recordset (anchor2, anchor3 etc). I chose the "anchor3" just as a test. The number of records placed on the page will be variable, so the anchor names will go up to a value of the number of records passed to the page.
 I need to link the anchors to the form submission so that when the form is submitted I will go to the place on the page from where the call to the GoBackTo() came from
Hope this makes sense
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Code now working - Thanks very much