Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Auto Generate Form Fields

(Page 2 of 4)
> > > >
Quote Reply
Post deleted by Addy In reply to
Quote Reply
Re: Auto Generate Form Fields In reply to
Who can solve this problem? (resetting of select and radio fields)

Alex, you have no idea?

Quote Reply
Re: Auto Generate Form Fields In reply to
Addy,

this is not the only problem to customize linksql. I wait also for answer in another thread about "modifying select-field column". Creating, modifying and displaying select- and checkbox-fields is a MUST to customize linksql.

Itīs very quiet about this topics, so I have the feeling that you need to wait for further releases .....

Not pretty, but seems to be reality.

Michael

Quote Reply
Re: Auto Generate Form Fields In reply to
Is there any reason why you posted the same post 4 times?

You can delete them by going to Edit > Delete

Paul Wilson.
Installations:
http://www.wiredon.net/gt/
Quote Reply
Re: Auto Generate Form Fields In reply to
Hi,

You could try:

Code:
sub {
my $html = $DB->html ( ['Users'], $IN );
return $html->select ( { name => 'Status', value => $IN->param('Status') });
}
Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: Auto Generate Form Fields In reply to
No, Paul I have no idea, why the message was displayed 4 times !! I only posted one. Now I saw it and deleted the 3 others.

Quote Reply
Re: Auto Generate Form Fields In reply to
Hi Alex,

I used your code and it works fine for select-fields, and I tried to use the code also for checkbox-fields in this way

sub {
my $html = $DB->html ( ['Users'], $IN );
return $html->checkbox ( { name => 'Status', value => $IN->param('Status') });}

The checkboxes where displayed fine at the add-form, but only the first selected checkbox-field will be saved.

Any ideas?

Michael


Quote Reply
Re: Auto Generate Form Fields In reply to
Hi All

In Reply To:
Are you trying to generate a select/radio list with the values being all the values in the database? Or are you trying to generate a select/radio list with the values being the allowed values for that field?
What I am interested in is generating a select box with the values allowed in a specific field for a specific record - all within link.html and detail.html - as with a web store catalog.

The link.html would be the specific product with its specific options (generated from its values in the fields), and the detail.html would have the same specific options with a larger image, etc.

So, for example, if you had a field called SIZE, and you had 500 records of, say, shoes and shirts, each with it's own range of values in the SIZE field, I want to build a select box for each link in link.html and detail.html containing just the values for each record. If there are no values in the Size field, a select box is not built.

Is this specifically what Alex's code will do, or does Alex's code snag all values up and down that entire column of values and build one big giant list of all values within the db for the Size field?

What I'm trying to do is use the script as a web store catalog, and being able to build select boxes for Item Options like Size by using just the values in the Size field for each ID is an important feature.

I hope that I have explained this well enough.

Thanks very much for your help. Smile

DT

Quote Reply
Re: Auto Generate Form Fields In reply to
Hi,

Probably best to use a bit of code to do this. I'm not 100% sure what you want to do, but this might help:

size_select_list =>
Code:
sub {
my $tags = shift;
my @allowed_sizes = split /\s+/, $tags->{Allowed_Sizes};
my $selected = $IN->param('Size');
my $output = '<select name="Size">';
foreach my $size (@allowed_sizes) {
if ($selected eq $size) {
$output .= "<option selected>$size";
}
else {
$output .= "<option>$size";
}
}
$output .= "</select>";
return $output;
}
To use that, you would add a column called Allowed_Sizes that would contain a space separated list of sizes that apply to this item. Then you would simply put:

<%size_select_list%>

to generate the select list.

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: Auto Generate Form Fields In reply to
Thank you so much, Alex. Smile

What I'm trying to do is set up a web store that can handle all kinds of pricing options (volume discounts and the like), item options (including options that adjust the price), shipping options, etc. - very flexible.

All these pricing and other options would be included in the database, and the output pages would be automatically built to work with my shopping cart.

This requires the ability to easily create and manage multiple select boxes, checkboxes, and radio buttons, as well as lots of hidden stuff.

To offer options that adjust the price, while still building the select boxes, some additional code has to be added to each option, and I'm concerned that the extra symbols might mess up the build process. For example, if I want to offer size options, and the 2XL and larger sizes involve an additional charge, the select options should look like this:

Small
Medium
Large
X-Large
XXL!+1.50
XXXL!+2.00

and the field value would look like this, given your code above using a space as a delimiter within the size field:

In Reply To:
Small Medium Large X-Large XXL!+1.50 XXXL!+2.00
Will the extra ! and + symbols mess up the building process?

Also, another thing that I want to do is offer volume discount pricing. This involves a string of pipe-delimited options for the cart to recognize the volume discount pricing scheme and also the use, again, of the ! symbol.

For example, the format that my shopping cart uses for volume discount pricing looks like the following:

In Reply To:
<input type=hidden name=id_price value="1-10!9.95|11-20!9.50|21-100!9.00">
I would have to include the full string of:

In Reply To:
1-10!9.95|11-20!9.50|21-100!9.00
in the "Price" field of X product, but my concern is that the pipes and the exclamation points will mess up the build process.

Should the cart's required pipes delimiters and exclamation points be escaped somehow so that the build process is unaffected, while safeguarding the integrity of the data that is to be transferred from the db to the output pages? Perhaps the quantity discount line and the size line should be enclosed in quotes.

Thank you so much, again. I really appreciate your help.SmileSmile

DT



Quote Reply
Re: Auto Generate Form Fields In reply to
In Reply To:
Will the extra ! and + symbols mess up the building process?
No, you can store whatever data you like in the fields and Links SQL won't care. My only concern would be that if you need a size with a space in it, you may want to pick a different delimiter. You could also use checkboxes or a multi-select list, and Links SQL will use newlines to delimit it automatically. That may be a better solution. All it would mean is changing the above to split on \n rather than \s.

As for the discounts, same answer. The build won't care about what's in the data.

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Auto Generate Form Fields In reply to
Hi Alex

This has worked great for select boxes. Bulls-eye!

What I am now trying to do is use something similar for creating checkboxes and radio buttons, where there are already values in a link field like Allowed_Sizes.

For example, there might be Allowed_Colors, etc.

I have been hacking away with the size_select_list stuff to build checkboxes and radio buttons, but I keep getting errors.

Here is what I'm trying for radio buttons:

Code:
sub {
my $tags = shift;
my @allowed_sizes = split /\s+/, $tags->{Allowed_Sizes};
my $selected = $IN->param('Size');
foreach my $size (@allowed_sizes) {
if ($selected eq $size) {
$output .= "<input type=radio name=Size value=$size checked> $size";
}
else {
$output .= "<input type=radio name=Size value=$size> $size";
}
}
return $output;
}

And, here is the current error message that I'm getting:

Quote:
A fatal error has occured:

Unable to compile 'size_radio_list'. Reason: Global symbol "$output" requires explicit package name at (eval 21) line 7.
Global symbol "$output" requires explicit package name at (eval 21) line 10.
Global symbol "$output" requires explicit package name at (eval 21) line 13.

How would I adjust things to be able to create checkboxes and radio buttons?

Many thanks, again, for your help. Smile

DogTags



------------------------------------------

Last edited by:

DogTags: Nov 18, 2001, 5:21 AM
Quote Reply
Re: [DogTags] Auto Generate Form Fields In reply to
** Bump **


------------------------------------------
Quote Reply
Re: [DogTags] Auto Generate Form Fields In reply to
Quote:
A fatal error has occured:

Unable to compile 'size_radio_list'. Reason: Global symbol "$output" requires explicit package name at (eval 21) line 7.
Global symbol "$output" requires explicit package name at (eval 21) line 10.
Global symbol "$output" requires explicit package name at (eval 21) line 13.
You can fix those error by adding a:
my $output;
above the foreach loop.


Adrian
Quote Reply
Re: [brewt] Auto Generate Form Fields In reply to
Thanks, Adrian!

Worked great Cool

------------------------------------------
Quote Reply
Re: [DogTags] Auto Generate Form Fields In reply to
You always need to code "strictly" when writing the code for globals (and in general it is a good thing)

You need to declare all variables with my()

Last edited by:

PaulW: Nov 28, 2001, 7:16 AM
Quote Reply
Re: [PaulW] Auto Generate Form Fields In reply to
Thanks, PaulW

I'll eventually get the hang of Links SQL...maybe

Cool

------------------------------------------
Quote Reply
Re: [Alex] Auto Generate Form Fields In reply to
Linksl 2.10

I wanted to use a custom-select-field at include_form.html and tried to use your code without success



size_select_list =>
Code:
sub {
my $tags = shift;
my @allowed_sizes = split /\s+/, $tags->{Allowed_Sizes};
my $selected = $IN->param('Size');
my $output = '<select name="Size">';
foreach my $size (@allowed_sizes) {
if ($selected eq $size) {
$output .= "<option selected>$size";
}
else {
$output .= "<option>$size";
}
}
$output .= "</select>";
return $output;
}

--
Michael Skaide

http://www.cycle24.de

Quote Reply
Re: [sangiro] Auto Generate Form Fields In reply to
Would there also be a way for doing this with Textboxes??

I'd need to generate anywhere from 1 to 6 textboxes in the same form, and each textbox would have to have a unique name.

Thanks very much. Smile

------------------------------------------
Quote Reply
Re: [DogTags] Auto Generate Form Fields In reply to
Hi There,

Not sure if this helps you too much, but this will allow you to autopopulate your form inputs.

Upload this file into your ../admin/ directory, yup the same directory as admin.cgi, and you will be able to do the following.

For text boxes

Code:
<%HTML::text( 'name' => 'textbox1' )%>

If you have something like ?....&textbox1=foobarbaz or a keyname in the tags for GT::Template it will create the appropriate HTML for a form textbox.

As well, if you add additional parameters as following:

Code:
<%HTML::text( 'name' => 'textbox1', 'size' => 12 )%>

It will add the size=12 attribute to the input tag. You can also force the value of the textbox by just adding a .... value => 'sometext'

Please note that support for radioboxes and checkboxes are a little bit iffy, the following code

Code:
<%HTML::checkbox( 'name' => 'checkbox1', 'value' => 'bar' )%>

Will create the checkbox, but only if you have ...&checkbox1=bar... will it be checked. (makes sense why, I hope Wink )

Take a look inside the module for what other form tags it supports.

Let me know if you have any problems.

Please note that if anyone wants to use this in their Links SQL plugin, please rename the package into your own namespace, store it in another location and use that version.... as the interface may yet change. (This is just a personnal module that I'm making public that may be of use to others)

Last edited by:

Aki: Jul 11, 2002, 4:13 PM
Quote Reply
Re: [Aki] Auto Generate Form Fields In reply to
Hey, thanks, Aki !

This looks really interesting. You've got a lot of form stuff in HTML.pm

I'm having a problem uploading the script into /admin, though. I've tried to FTP your file into the /admin directory, but I'm getting denied - 550

I can upload stuff to the /templates directory, and even rename, etc., but for some reason, files at the /admin level seem to have other restrictions, but I can't seem to identify anything different.

Would you have any suggestions??

Many thanks for your help. Smile

------------------------------------------
Quote Reply
Re: [DogTags] Auto Generate Form Fields In reply to
np ;)

Make sure that the admin/ directory's chmod has been set to something 777 (temporarily) so that you can upload using ftp. Maybe try uploading using fileman as well, you might have better luck.
Quote Reply
Re: [Aki] Auto Generate Form Fields In reply to
Thanks muchly, Aki !

I'll give it a go. I appreciate your help. Smile Smile

------------------------------------------
Quote Reply
Re: [Aki] Auto Generate Form Fields In reply to
Fileman upload a success.

Thanks, Aki ! Smile

------------------------------------------
Quote Reply
Re: [Alex] Auto Generate Form Fields In reply to
Alex,

I used this piece of code and it seems to work fine. How can this be changed to build the list from values in a different installation of LinksSQL than the one you're displaying it in?

Safe swoops
Sangiro
> > > >