Jump to content

Adding fields


OriginalBoy

Recommended Posts

"I want it so if they change the value of the website pages I want it to add more fields so there is a box for each page."

 

Huh?  Can you elaborate?

 

 

As with any user input, you'll need to store it somewhere, and then dynamically display it.

 

For example, you may have a page where users can submit information, and then this information will be stored in a database.  Your other pages then retrieve that information from the database.

Link to comment
https://forums.phpfreaks.com/topic/110332-adding-fields/#findComment-566084
Share on other sites

Oh I get it now, a quote as in price estimate.  I was thinking quote as in: Corbin said, "Hello!"

 

OK hrmmmm...

 

You could do it in javascript, and the page wouldn't have to reload, but here's how you could do it in PHP:

 

<?php

$showform = true;

if($_POST) {
$page_cnt = (isset($_POST['page_cnt'])) ? (int) $page_cnt : null; //if the post val is set, use it, else use null...  If it is set, cast it to an integer...
if($page_cnt > 0 && $page_cnt < 100) { //0 < page count < 100...I doubt anyone would have a legit reason for saying more than 100 pgs.... really even 20... but... lol
	$showform = false;
	echo '<form action="" method="POST">'
	for($i = 0; $i < $page_cnt; ++$i) {
		echo '<textarea name="page[]"></textarea>';
	}
	echo '<input type="submit" value="Go!" />';
	echo '</form>';
}
else {
	echo 'Please select a valid Page Count.';
}
}

if($showform) {
//user hasn't chosen a number, or it was an invalid number
}
?>

 

 

 

You would need to mod that for it to actually be of any use, but it should be a start to atleast show you how to do it.

Link to comment
https://forums.phpfreaks.com/topic/110332-adding-fields/#findComment-566091
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.