Overclock.net - Overclocking.net
     
 
Home Gallery Reviews Blogs Register Today's Posts Mark Forums Read Members List


Go Back   Overclock.net - Overclocking.net > Software, Programming and Coding > Coding and Programming > Web Coding

Reply
 
LinkBack Thread Tools
Old 06-28-08   #1 (permalink)
First Time Build
 
Fkyx's Avatar
 
intel nvidia

Join Date: Jun 2007
Location: Klamath Falls, OR
Posts: 681

Rep: 68 Fkyx is acknowledged by some
Unique Rep: 59
Trader Rating: 0
Default Quick PHP/HTML Forms question.

Alright. So I'm writing a simple gallery script for my dad's website.

For this gallery, I have a separate form for adding images to a specific album. I'd like to have a SELECT that will allow the user to choose how many images will be added to the album. Choosing to add 3 images would "refresh" the form to have 3 upload boxes.

How do I go about writing this? Is it as simple as this:

...
print<<<end
<select name="numImages">
<option value = 1>1</option>
<option value = 2>2</option>
<option value = 3>3</option>
<option value = 4>4</option>
<option value = 5>5</option>
</select>
<br>
end;

$i=0;
while($i < $numImages)
{
print "<input name=\"images[]\" type=\"fill\">";
print "<br>";
}
...


Something tells me that's not it.

Thanks.
__________________
---Building Jillian--- Watch out, 56k. She's Finished!!!
Guide: Replacing the Fan in a Tuniq Tower 120 - Another 56k killer.
Guide: Removing the HDD from a WD MyBook Essential - 56k okay.

Fkyx's lucky day...?

Quote:
Originally Posted by MrBungle View Post
i'm not smart, but i'm beautiful. let me know if you need a beautiful person.

System: Jillian
CPU
Intel E6420 @ 2.13ghz
Motherboard
Gigabyte 965P-DS3 Rev. 3.3
Memory
G.Skill 2x2GB DDR2
Graphics Card
eVGA 8800GTS 640mb
Hard Drive
Western Digital 3200AAKS 320gb
Power Supply
Corsair 520HX
Case
Cooler Master Stacker 830
CPU cooling
Tuniq Tower 120
OS
Vista Business
Monitor
Ben-Q FP202W V3 20" Widescreen
Fkyx is offline   Reply With Quote
Old 07-05-08   #2 (permalink)
ATI Enthusiast
 
mentholmoose's Avatar
 
intel ati

Join Date: Jan 2007
Location: Pennsylvania
Posts: 765

Rep: 72 mentholmoose is acknowledged by some
Unique Rep: 66
Trader Rating: 29
Default

You need JavaScript to do that code because PHP is all server-side code and won't work to dynamically change anything on the client side. I don't know enough Javascript to help you out with it, though.
__________________
Quote:
Originally Posted by CorporalAris
Hey, look, OCN is back up. My god, it goes down so often I'm starting to get chafed... :/

System: down, down, down [potential additions in brackets]
CPU
Lapped E7200 [Q9550]
Motherboard
Gigabyte GA-X48-DQ6
Memory
4GB G.SKILL DDR2-1000 [8GB]
Graphics Card
Sapphire HD 3870 [and a 3870X2, or an HD 4870]
Hard Drive
Seagate 250GB + WD 500GB [Seagate 1TB]
Power Supply
Seasonic M12-700
Case
Lian-Li PC-A05B
CPU cooling
None [Enzotech Ultra-X]
GPU cooling
Thermalright HR-03 GT
OS
LiveCD [Mac OS X / Ultimate x64 / Gentoo 2008.0]
Monitor
Dell Ultrasharp 2407WFP-HC
mentholmoose is offline mentholmoose's Gallery   Reply With Quote
Old 07-06-08   #3 (permalink)
Programmer
 
metala's Avatar
 
intel ati

Join Date: Aug 2006
Location: Blagoevgrad, Bulgaria
Posts: 531

Rep: 19 metala Unknown
Unique Rep: 18
Trader Rating: 0
Default

Quote:
Originally Posted by Fkyx View Post
Alright. So I'm writing a simple gallery script for my dad's website.

For this gallery, I have a separate form for adding images to a specific album. I'd like to have a SELECT that will allow the user to choose how many images will be added to the album. Choosing to add 3 images would "refresh" the form to have 3 upload boxes.

How do I go about writing this? Is it as simple as this:

...
print<<<end
<select name="numImages">
<option value = 1>1</option>
<option value = 2>2</option>
<option value = 3>3</option>
<option value = 4>4</option>
<option value = 5>5</option>
</select>
<br>
end;

$i=0;
while($i < $numImages)
{
print "<input name=\"images[]\" type=\"fill\">";
print "<br>";
}
...


Something tells me that's not it.

Thanks.
It will work if you make to forms.
First is the select input. And set attribute on the select onchange="this.form.submit();"
The other form will be generated dynamically by the PHP.
i.e. $numImages = $_POST['from_the_first_form'].
And afther that you have to put make an iteration of the $_FILES superglobal array, in order to work with the uploaded files.

But with Javascript will be better.. the only problem is that wit will be more complex/difficult to be done.
__________________
Debian worshipper
Quote:
Originally Posted by mct75 View Post
I get tired of seeing every AMD thread ragged to death by intel users saying AMD sucks.
I use an AMD processor but I respect intel users enough to not go into their threads and harass them to death.

System: Korpus
CPU
Core 2 Duo E6750@1.144V stable
Motherboard
Asus P5K
Memory
4 x 1GB Kingmax @ 1066MHz DDR2
Graphics Card
Sapphire Radeon HD 2600 XT 256MB GDDR3 850/810
Hard Drive
320GB Seagate ST3320620AS
Sound Card
24bit ALC883 7.1+2 & ATI's HDMI
Power Supply
FORTRON PNF-350
Case
Куча марка (Generic...
CPU cooling
Stock
GPU cooling
Stock
OS
Debian Lenny + Windows XP
Monitor
Philips 19S7FS
metala is online now   Reply With Quote
Old 07-14-08   #4 (permalink)
PC Gamer
 
NessTheHero's Avatar
 
intel nvidia

Join Date: May 2008
Location: Pittsburgh
Posts: 315
Blog Entries: 2

Rep: 29 NessTheHero is acknowledged by some
Unique Rep: 28
Folding Team Rank: 332
Hardware Reviews: 1
Trader Rating: 0
Default

look into AJAX and XMLHttpRequest
__________________
I have four words for you...
DEVELOPERS DEVELOPERS DEVELOPERS DEVELOPERS
Five thousand, two hundred, and eighty points per day


Next upgrades: 150 GB Raptor; 24" Monitor; 9800 GTX 4 SLI; Q6600; Auzentech Prelude;
* Waiting on Sandy Bridge *

System: Legendary Awesome
CPU
C2D E4600 2.88GHz OC'd 20% through BIOS
Motherboard
ASUS Striker Extreme
Memory
G.Skill DDR2 800 4GB
Graphics Card
XFX GeForce 9800 GTX(G92) 512MB
Hard Drive
160, 250, 1000
Sound Card
SoundMax HD Audio card
Power Supply
600W
Case
Antec Twelve Hundred
CPU cooling
Zalman Copper heatsink
GPU cooling
Stock
OS
Vista Home Premium x64
Monitor
Two 19 inch monitors
NessTheHero is offline I fold for Overclock.net   Reply With Quote
Old 07-17-08   #5 (permalink)
Programmer
 
LyokoHaCk's Avatar
 
amd nvidia

Join Date: Aug 2006
Location: United States Inc.
Posts: 1,976

Rep: 73 LyokoHaCk is acknowledged by some
Unique Rep: 68
FAQs Submitted: 1
Folding Team Rank: 1797
Trader Rating: 2
Default

Quote:
Originally Posted by mentholmoose View Post
You need JavaScript to do that code because PHP is all server-side code and won't work to dynamically change anything on the client side. I don't know enough Javascript to help you out with it, though.
ajax
LyokoHaCk is offline I fold for Overclock.net   Reply With Quote
Old 07-18-08   #6 (permalink)
Programmer
 
metala's Avatar
 
intel ati

Join Date: Aug 2006
Location: Blagoevgrad, Bulgaria
Posts: 531

Rep: 19 metala Unknown
Unique Rep: 18
Trader Rating: 0
Default

Quote:
Originally Posted by LyokoHaCk View Post
ajax
You people, are AJAX obsessed, aren't you?

I would use AJAX only in case of not knowing how to program in JavaScript.
I was thinking of a simple solution:
Code:
<script>
function generateUploadInputs(num){
 inputCont = document.getElementById('uploadInputs');
 inputCont.innerHTML = '';
 for (var i =0; i < num; i++) inputCont.innerHTML += '<input type="file" name="images[]" />n<br />';
}
</script>
<select name="numImages" onchange="generateUploadInputs(this.options[this.selectedIndex]);">
<option value = 1>1</option>
<option value = 2>2</option>
<option value = 3>3</option>
<option value = 4>4</option>
<option value = 5>5</option>
</select>

<div id="uploadInputs">

</div>
__________________
Debian worshipper
Quote:
Originally Posted by mct75 View Post
I get tired of seeing every AMD thread ragged to death by intel users saying AMD sucks.
I use an AMD processor but I respect intel users enough to not go into their threads and harass them to death.

System: Korpus
CPU
Core 2 Duo E6750@1.144V stable
Motherboard
Asus P5K
Memory
4 x 1GB Kingmax @ 1066MHz DDR2
Graphics Card
Sapphire Radeon HD 2600 XT 256MB GDDR3 850/810
Hard Drive
320GB Seagate ST3320620AS
Sound Card
24bit ALC883 7.1+2 & ATI's HDMI
Power Supply
FORTRON PNF-350
Case
Куча марка (Generic...
CPU cooling
Stock
GPU cooling
Stock
OS
Debian Lenny + Windows XP
Monitor
Philips 19S7FS

Last edited by metala : 07-18-08 at 09:19 AM.
metala is online now   Reply With Quote
Old 07-18-08   #7 (permalink)
PC Gamer
 
NessTheHero's Avatar
 
intel nvidia

Join Date: May 2008
Location: Pittsburgh
Posts: 315
Blog Entries: 2

Rep: 29 NessTheHero is acknowledged by some
Unique Rep: 28
Folding Team Rank: 332
Hardware Reviews: 1
Trader Rating: 0
Default

You shouldn't rely on innerHTML. That standard has been deprecated.

Look into using the DOM (Document Object Model). With that, you create elements on the fly and it has better compatibility with most browsers. It's also easier to use with XML requests.
__________________
I have four words for you...
DEVELOPERS DEVELOPERS DEVELOPERS DEVELOPERS
Five thousand, two hundred, and eighty points per day


Next upgrades: 150 GB Raptor; 24" Monitor; 9800 GTX 4 SLI; Q6600; Auzentech Prelude;
* Waiting on Sandy Bridge *

System: Legendary Awesome
CPU
C2D E4600 2.88GHz OC'd 20% through BIOS
Motherboard
ASUS Striker Extreme
Memory
G.Skill DDR2 800 4GB
Graphics Card
XFX GeForce 9800 GTX(G92) 512MB
Hard Drive
160, 250, 1000
Sound Card
SoundMax HD Audio card
Power Supply
600W
Case
Antec Twelve Hundred
CPU cooling
Zalman Copper heatsink
GPU cooling
Stock
OS
Vista Home Premium x64
Monitor
Two 19 inch monitors
NessTheHero is offline I fold for Overclock.net   Reply With Quote
Old 07-20-08   #8 (permalink)
Programmer
 
metala's Avatar
 
intel ati

Join Date: Aug 2006
Location: Blagoevgrad, Bulgaria
Posts: 531

Rep: 19 metala Unknown
Unique Rep: 18
Trader Rating: 0
Default

Quote:
Originally Posted by NessTheHero View Post
You shouldn't rely on innerHTML. That standard has been deprecated.
I don't remember innerHTML to have ever been in the W3C specifications, however:
Quote:
Originally Posted by http://www.w3schools.com/htmldom/dom_methods.asp
The easiest way to get or modify the content of an element is by using the innerHTML property.

innerHTML is not a part of the W3C DOM specification. However, it is supported by all major browsers.
I was just looking for the easiest way to demonstrate what I mean. Creating objects and appending then to a node is somehow far more difficult than appending string.

PS. I have lots of experience with the DOM, especially DOM2 Event


Quote:
Originally Posted by NessTheHero View Post
Look into using the DOM (Document Object Model). With that, you create elements on the fly and it has better compatibility with most browsers. It's also easier to use with XML requests.
I'm interested in it. Can you give me an example?
PS. I haven't thought another way than http://en.wikipedia.org/wiki/AXAH .
EDIT43: I found it... http://www.w3schools.com/Ajax/ajax_responsexml.asp
Damn it is a lot more source code than just using the innerHTML. And if you look through other ajax tutorials at w3schools you will see that they are mostle using innerHTML.
__________________
Debian worshipper
Quote:
Originally Posted by mct75 View Post
I get tired of seeing every AMD thread ragged to death by intel users saying AMD sucks.
I use an AMD processor but I respect intel users enough to not go into their threads and harass them to death.

System: Korpus
CPU
Core 2 Duo E6750@1.144V stable
Motherboard
Asus P5K
Memory
4 x 1GB Kingmax @ 1066MHz DDR2
Graphics Card
Sapphire Radeon HD 2600 XT 256MB GDDR3 850/810
Hard Drive
320GB Seagate ST3320620AS
Sound Card
24bit ALC883 7.1+2 & ATI's HDMI
Power Supply
FORTRON PNF-350
Case
Куча марка (Generic...
CPU cooling
Stock
GPU cooling
Stock
OS
Debian Lenny + Windows XP
Monitor
Philips 19S7FS

Last edited by metala : 07-20-08 at 07:02 PM.
metala is online now   Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools



All times are GMT -4. The time now is 07:21 AM.


Overclock.net is a Carbon Neutral Site Creative Commons License Internet Security By ControlScan

Terms of Service / Forum Rules | Privacy Policy | Advertising | Become an Official Vendor
Copyright © 2008 Shogun Interactive Development. Most rights reserved.
Page generated in 0.19084 seconds with 9 queries