LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-12-2005, 09:38 PM   #1
rose_bud4201
Member
 
Registered: Aug 2002
Location: St Louis, MO
Distribution: Xubuntu, RHEL, Solaris 10
Posts: 929

Rep: Reputation: 30
Changing a table contents dynamically based on select box


I'm trying to do something seemingly simple, but about which there is an astounding lack of information.
I've got what is right now a static web page, with a very large table full of images. What I'd like to do is divide up those images into categories, and create a select box the contents of which will determine which category of images to actually write to the page.

I *thought* I'd done something like this before, perhaps having the onChange call set a variable, or call a function to determine which option is selected and then write the correct part of the page...i.e.

<select>
<option value="something1" onChange="some function setting var imageCategory to '1'">
<option value="something2" onChange="some function setting var imageCategory to '2'">
</select>

<?php
if (imageCategory == 1)
{
echo("<table>");
echo("<tr><td><img blah blah blah></td></tr>");
echo("</table>");
}
else if(imageCategory == 1)
{
you get the picture.
}
?>

I realize that there are some inconsistencies in there, namely in getting the php to re-run (or the page to resubmit, whichever comes first), but if I knew the answers I wouldn't be asking, would I?

Many thanks for any help,
-Laura
 
Old 01-12-2005, 09:54 PM   #2
barryman_5000
Member
 
Registered: Jan 2005
Distribution: Gentoo/Vector/Debian
Posts: 95

Rep: Reputation: 15
ok, instead of using php why not use frames or a simple document.write() in javascript?

Anyhow, lets say your selection page has this form

<form action="images.php" method="POST">
<select>
<option value="true" name="Category_1">
<option value="true" name="Category_2">
</select>
<input type="submit" value="submit" />
</form>

Then images.php will have this:

if ($_POST['Category_1']){
'show one category
}
if ($_POST['Category_2']){
'show two category
}

The truth is this would be alot easier to make separate static pages if you only have two categories. I don't see a reason for making this overly complicated
 
Old 01-13-2005, 08:16 AM   #3
rose_bud4201
Member
 
Registered: Aug 2002
Location: St Louis, MO
Distribution: Xubuntu, RHEL, Solaris 10
Posts: 929

Original Poster
Rep: Reputation: 30
mm, but see - the issue is not to show different pages' worth of icons, it's to divide them up into some sort of smaller categories so that I don't have to look at them all at once. There aren't just 2, there are closer to 7 or 8.

This isn't for some grand project - it's just for my personal blog, which is sort of a reverse-engineered livejournal. I've gotten to the point where I've got upwards of 60 icons, and currently am statically displaying them in one gigantic table on my "Post" page...I'd like to split them up so that I can select a category, and display only the appropriate icons.

The trick is, the table with the icons is of course part of a form already, which has a couple of text boxes, a text area, and which submits to a script ultimately displaying the new post on the main page. So giving the icons their own form isn't really an option.

There's *got* to be a way, somehow, to change a page's contents at runtime based on some form of user input...
I'm not even all that locked into using a select box, just something that will display selectable categories.
 
Old 01-13-2005, 10:17 AM   #4
barryman_5000
Member
 
Registered: Jan 2005
Distribution: Gentoo/Vector/Debian
Posts: 95

Rep: Reputation: 15
Javascript can do that easily via a document.write() -- You can even include all the code (and set it to prefetch all the images too) if you want. Just research on the document.write some as that is what will be good for a runtime-based client-side interaction.
 
Old 01-13-2005, 10:48 AM   #5
rose_bud4201
Member
 
Registered: Aug 2002
Location: St Louis, MO
Distribution: Xubuntu, RHEL, Solaris 10
Posts: 929

Original Poster
Rep: Reputation: 30
I'll do that - thanks very much for your help!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
RIP 1 question : How to access the contents of a routing table within a program ? prashanth s j Linux - Networking 1 10-25-2005 08:27 AM
How to access the contents of routing table within a program?(for RIP1) prashanth s j Linux - Networking 1 09-03-2005 04:29 AM
phpBB2 contents go to the _blank_ table.. miguetoo Linux - Software 0 12-13-2004 01:21 PM
SELECT data from Table Gerardoj Programming 2 04-16-2004 11:50 PM
changing samba configuration dynamically ramu_ak Linux - Networking 1 12-28-2003 02:24 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:30 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration