Page 1 of 1

sub menu item as a form entry

PostPosted: Mon Apr 01, 2013 7:44 pm
by tomrconsulting
How do I use your product to drive a select box (drop-down list) in a PHP form.

I would like the drop down list to be a menu with the list of items contained in the submenus so I can pass a unique value for each menu item to a PHP form.

Re: sub menu item as a form entry

PostPosted: Mon Apr 01, 2013 10:58 pm
by Aivars
You can use JavaScript for that. To assign JavaScript actions to menu items, use this for Link:

javascript:your_function_name();

Re: sub menu item as a form entry

PostPosted: Mon Apr 01, 2013 11:56 pm
by tomrconsulting
This is what I'm trying to do. Not sure how I pass the Javascript
javascript:your_function_name();

would i put the link down as javascript:building_id(001) in the link for submenu for Building 001
javascript:building_id(002) in the link for submenu for Building 002
etc

Then how do I pass it to the next page. Below is what I'm doing now but would look much better if I could use your button and a menu


<form action="building_id.php" method="post">
Name: <input type="text" id="bldg_id">
<input type="submit">
</form>
Below is "building_id .php" file I use the $_POST variable to drive the page information

<html>
You are in Building Number <?php echo $_POST["bldg_id"]; ?>!<br>

or I use it in http\\tom.building.edu\images\<?php echo $_POST["bldg_id"]; ?>.jpg

http\\tom.building.edu\php_reports\<?php echo $_POST["bldg_id"]; ?>.php

</html>

Re: sub menu item as a form entry

PostPosted: Tue Apr 02, 2013 11:21 am
by Aivars
I recommend to get a JavaScript programmer's help for this. The basic idea is to use a hidden form field and make clicking menu entries change value of this field via JavaScript function. Using your example, you can declare function building_id as:

Code: Select all
<script>
function building_id(id) {
  document.getElementById('building_id').value = id;
}
</script>


Optionally you can also submit the form via JavaScript after filling in the building_id value.

> would i put the link down as javascript:building_id(001) in the link for submenu for Building 001
javascript:building_id(002) in the link for submenu for Building 002
etc

This would work, except if you need to precede with zeros then pass string values instead e.g. javascript:building_id('001')