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