Jump to content

Fire Up A Php Code Based On A Selected Form Field


50r

Recommended Posts

hello freaks i have a database table of tbl_menus (working on content management part of my script).

 

menus are ordered according to the position in the table field position.

 

on the site we have 4 spots for menus called modules but all menus are stored in one table tbl_menus

 

we also have a field module in the table.

 

now on the form in new menu.php

 

the position will be based on the number of row based on the module field.

the position select options are populated according to the number of row based on the module field.

 

that mean while am creating a new menu, to populate the right number of row for someone to pick a position, i have to first run an sql count query base on a selection of the module.

 

Javascript would be the base solution but how do i go about it?

Link to comment
Share on other sites

some where on google i saw this example but can someone try to break down for me cause i am failing to get it work.

 

   <script>
   function showDetails(id)
   {
   if (window.XMLHttpRequest)
   {// code for IE7+, Firefox, Chrome, Opera, Safari
   xmlhttp=new XMLHttpRequest();
   }
   else
   {// code for IE6, IE5
   xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
   }
   xmlhttp.onreadystatechange=function()
   {
   if (xmlhttp.readyState==4 && xmlhttp.status==200)
   {
   document.getElementById("details").innerHTML=xmlhttp.responseText;
   }
   }
   xmlhttp.open("GET","test.php?q="+id,true);
   xmlhttp.send();
   }
   </script>
   <select name="users" onchange="showDetails(this.value)">
   <option value="">Select:</option>
   <option value="1">1</option>
   <option value="2">2</option>
   </select>
   <div id='details'></div>

Link to comment
Share on other sites

erm...perhaps the javascript forum would have been better? I did something simmilar just recently using PHP+JQueryUI to let members choose a default layout for portlets, and that code you have there looks to do nothing more than a simple ajax request to load content into a div depending on which option is picked, it doesn't communicate with anything that would preserve the info after page close.

 

What I did only had 3 columns to handle, so I just defined a col_id of 0-3 in the table with 0 being not shown, 1 being left, 2 center and 3 right, then loaded the locations through a couple of loops. a static dropdown did for the location chooser in the account admin area to update which portlet went where.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.