1
Peekay
How do you put text from a menu option into a variable?
  • 2008/4/6 13:20

  • Peekay

  • XOOPS is my life!

  • Posts: 2335

  • Since: 2004/11/20


There is a form used to edit an item in the Alumni module (modlisting.php) which includes a drop-down menu of the available categories.

Around line 157:

$mytree->makeMySelBox("title""title"$cide);

When the form is viewed, it renders options, e.g.

Main category
-- Sub cat one
-- Sub cat two

The selected option is displayed based on retrieving $cide.

My problem is this:

When a NEW item is created, it's category name is recorded in the DB in a row 'school'. If a user edits the item and changes the category, the item appears correctly under the new category heading. The problem is that the 'school' row in the DB is not updated.

I can see how to achieve this in modlisting.php except for one thing... I don't know how to get the text of the new selected menu option into a variable.

In essence, I need:

$school $_POST['text of the new menu choice'];


Can anyone help?
A thread is for life. Not just for Christmas.

2
Peekay
Re: How do you put text from a menu option into a variable?
  • 2008/4/8 17:54

  • Peekay

  • XOOPS is my life!

  • Posts: 2335

  • Since: 2004/11/20


No coders out there familiar with this?

P.S When is someone gonna make smilies work properly on this forum. Not showing off XOOPS at it's best really.
A thread is for life. Not just for Christmas.

3
Peekay
Re: How do you put text from a menu option into a variable?
  • 2008/4/12 14:12

  • Peekay

  • XOOPS is my life!

  • Posts: 2335

  • Since: 2004/11/20


Does nobody know how to work with this object?
A thread is for life. Not just for Christmas.

4
trabis
Re: How do you put text from a menu option into a variable?
  • 2008/4/12 15:35

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Take a look at the source code of the form (html)

In this comment submit form for example I have this:



If i was to get the value of this form I would have to find the name of the form (ex:name="editor"), so I would use:

$value=$_POST['editor'];


Ps:I did not understand your problem, can you explain it better?

5
Peekay
Re: How do you put text from a menu option into a variable?
  • 2008/4/12 20:45

  • Peekay

  • XOOPS is my life!

  • Posts: 2335

  • Since: 2004/11/20


Thx for responding Trabis.

I checked the HTML generated by the makeMySelBox object and in this case it is:
<select name='cid'>
<
option value='1'>Main Categoryoption>
<
option value='2'>--&nbsp;Sub cat oneoption>
<
option value='3' selected='selected'>--&nbsp;Sub cat twooption>
select>

I can grab the values '1', '2' or '3' but not the option text.

It appears a $cat variable exists which carries the updated category number, so to set the 'school' var I opted for a simpler solution and just added a conditional statement:

if($cat == '2') {
      
$school "Sub cat one";  etcetc....

It's not dynamic, but it solves my particular problem.
A thread is for life. Not just for Christmas.

Login

Who's Online

402 user(s) are online (277 user(s) are browsing Support Forums)


Members: 0


Guests: 402


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits