Inserting List data into form automatically

3 posts by 2 authors in: Forums > CMS Builder
Last Post: January 29, 2009   (RSS)

Re: [misery217] Inserting List data into form automatically

By Dave - January 28, 2009

Hi misery217,

This is a bit outside the scope of CMS Builder support but here's some tips:

- You can pass values in the url like this: ?name=value

- If you're passing a value from CMS Builder you'll want to url encode it. Instead of <?php echo $record['field'] ?> you'd use <?php echo urlencode($record['field']) ?>

- So your link might look like this:
index.html?product=<?php echo urlencode($record['product']) ?>

- Now, in order to read that value back you're going to need to switch index.htm to index.php.

- Then you could display that value in the field by default like this:
<input name="product" type="text" id="product" size="45" value="<?php echo htmlspecialchars(@$_REQUEST['product']) ?>" />

A few explanations. urlencode() encodes things like space as %20 or + so they work in your urls. Same as you see when you submit a google search where some characters get encoded.

htmlspecialchars() encodes special characters as "html entities" so " becomes &quot; so if your product value had a " in it it wouldn't break your text field (which uses quotes around the value).

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Inserting List data into form automatically

Thank you!! Once configured this works FANTASTICALLY!

Thanks again Dave!