sub menu item as a form entry

Post your questions and problem reports here.

sub menu item as a form entry

Postby tomrconsulting » Mon Apr 01, 2013 7:44 pm

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.
tomrconsulting
 
Posts: 2
Joined: Mon Apr 01, 2013 7:14 pm

Re: sub menu item as a form entry

Postby Aivars » Mon Apr 01, 2013 10:58 pm

You can use JavaScript for that. To assign JavaScript actions to menu items, use this for Link:

javascript:your_function_name();
Blumentals Software Programmer
User avatar
Aivars
Blumentals Software Developer
 
Posts: 2453
Joined: Thu Aug 22, 2002 1:40 pm
Location: Latvia

Re: sub menu item as a form entry

Postby tomrconsulting » Mon Apr 01, 2013 11:56 pm

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>
tomrconsulting
 
Posts: 2
Joined: Mon Apr 01, 2013 7:14 pm

Re: sub menu item as a form entry

Postby Aivars » Tue Apr 02, 2013 11:21 am

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')
Blumentals Software Programmer
User avatar
Aivars
Blumentals Software Developer
 
Posts: 2453
Joined: Thu Aug 22, 2002 1:40 pm
Location: Latvia


Return to Easy Button & Menu Maker Support

Who is online

Users browsing this forum: No registered users and 14 guests

cron