Gossamer Forum
Home : Products : Links 2.0 : Customization :

Passing checkbox values to add_error.html or modify_error.html

Quote Reply
Passing checkbox values to add_error.html or modify_error.html
How could I pass checkbox, radiobutton, downdrop box selection to the next page (add_error.html or modify.html)?
You know, you can pass variables, e.g.: <%Description%>, <%URL%>, etc.
But how can be made to pass e.g. a downdrop box selection?
Example:
<select name="select">
<option value="city1">city 1</option>
<option value="city2">city 2</option>
<option value="city3" selected>city 3</option>
<option value="city4">city 4</option>
</select>

It's rather difficult, since the "selected" option can be in any row.
I could imagine a solution like this:
<select name="select">
<option value="city1" <%isselected1%>>city 1</option>
<option value="city2" <%isselected2%>>city 2</option>
<option value="city3" <%isselected3%>>city 3</option>
<option value="city4" <%isselected4%>>city 4</option>
</select>

Links should pass the "selected" value to the <%isselected3%> in the example above,
and the other <%isselected%> variables should contain nothing.
Of course, using checkboxes or radiobuttons, "checked" should be used intead "selected".

I found a thread about Checkbox field in add.cgi, but it's not enough using so many options.
http://www.gossamer-threads.com/...um3/HTML/000993.html
There can be a lot options even 10-20, so a simple if..else couldn't work in site_html_add_form or site_html_add_failure subroutines.

Could anybody help me in this problem?

Thanks in advance,
Webmaster33

[This message has been edited by webmaster33 (edited January 23, 2000).]
Quote Reply
Re: Passing checkbox values to add_error.html or modify_error.html In reply to
You will have to add all the options as stated in the other file for this to work.

Also, you are linking the tag incorrectly in your add_error.html template file.

Simply use the following:

Code:
<%isselected%>

isseletected should be defined as the following:

Code:
isselected => $isselected,

Then in your sub site_html_add_failure routine, add the following codes:

Code:
if ($in{'City'} eq "city1") {
my $isselected = qq|City:
<select name="City">
<option value="city1" SELECTED>city 1</option>
<option value="city2">city 2</option>
<option value="city3">city 3</option>
<option value="city4">city 4</option>
</select>|;
}
if ($in{'City'} eq "city2") {
my $isselected = qq|City:
<select name="City">
<option value="city1">city 1</option>
<option value="city2" SELECTED>city 2</option>
<option value="city3">city 3</option>
<option value="city4">city 4</option>
</select>|;
}
else {
my $isselected = qq|City:
<select name="City">
<option value="city1">city 1</option>
<option value="city2">city 2</option>
<option value="city3">city 3</option>
<option value="city4">city 4</option>
</select>|;
}

Code:
<select name="City">
<option value="city1">city 1</option>
<option value="city2">city 2</option>
<option value="city3" selected>city 3</option>
<option value="city4">city 4</option>
</select>

Change City to the exact name of the field.

IF these codes do NOT work, then you can simply use the same type of codes that you use for Categories in the sub site_html_add_form AND sub site_html_add_failure, like the following:

Code:
my $clean_city = &build_clean($city);
$city ?
($city = qq~$clean_city <input type=hidden name="City" value
="$city">~) :
($city = &build_select_field ("City", "$in{'City'}"));

Then define the City tag in the following manner:

Code:
City => $city,

Then in your template files (add.html, add_error.html, add_success.html), add the following codes:

Code:
City: <%City%>

You may also have to tinker with the db_utils.pl file to dynamically create the select fields for City...Let me know if this doesn't work, then I can provide some codes you will have to add to the db_utils.pl file.

You also should be using the following codes for your select field.

Hope this helps.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
* Be sure to visit the Resource Center for FAQ's, Modifications and Extra Goodies!!
* Search Forums!
* Say NO to Duplicate Threads. Smile
----------------------









[This message has been edited by Eliot (edited January 23, 2000).]

[This message has been edited by Eliot (edited January 24, 2000).]
Quote Reply
Re: Passing checkbox values to add_error.html or modify_error.html In reply to
Sorry, I didn't notice, that there are 2 examples. Now I see Smile
Well, maybe the 2nd. example will work, I will try it right now.
I'll back in 10-15 minutes...
Quote Reply
Re: Passing checkbox values to add_error.html or modify_error.html In reply to
Eliot: This is not the solution I wanted.
I wrote that this solution is wrong because the following code should repeated so many times as many options are. Don't you think it will slow the process very much, with even 10-20-30 options? It will!

Code:
if ($in{'City'} eq "city1") {
my $isselected = qq|City:
<select name="City">
<option value="city1" SELECTED>city 1</option>
<option value="city2">city 2</option>
<option value="city3">city 3</option>
<option value="city4">city 4</option>
</select>|;}

>"Also, you are linking the tag incorrectly in your add_error.html template file."
It was suggestion for a solution, not the solution I use now. Smile
Well, I plan to write a mod for this, then I will post here, later.
A basic draft of it:
1) I will use a option_city.db file to store the cities. E.g.: 1|New York|newyork
2) Then match the selected option value(newyork) to get the row number.
3) Pass the number to next page by <input type=hidden name=isselected value="<%isselected%>">
4) Pass "selected" text value to the <%isselected3%> (the number of <%isselectedX%> is determined by <%isselected%> numeric value).

This above is just a basic draft, but I know it will work.
Your opinion counts me, so let me know what you say about it!

Regards,
Webmaster33

[This message has been edited by webmaster33 (edited January 24, 2000).]
Quote Reply
Re: Passing checkbox values to add_error.html or modify_error.html In reply to
Even with the second example I gave????

The second example will DYNAMICALLY build a select field drop-down menu based on the values included in the City field in your add forms and modify forms (error pages). RATHER than manually typing in codes every time that the values of these fields do not change.

Okay...if you are going to create another database...how are you going to align records when printing them in your directory or via the search engine, and also delete corresponding records from each database????

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
* Be sure to visit the Resource Center for FAQ's, Modifications and Extra Goodies!!
* Search Forums!
* Say NO to Duplicate Threads. Smile
----------------------









[This message has been edited by Eliot (edited January 24, 2000).]
Quote Reply
Re: Passing checkbox values to add_error.html or modify_error.html In reply to
I tried your 2nd example. It took a bit time. Smile

Well, it works fine, now.
It's not right the same result as I was looking for, but definitely works.
(I wanted the result, to have a downdrop box on the error page, with the selected one from the previous page).
However your solution is very fine for me.
Thanks Eliot for your solution! You saved me hours of work, which would be unnecessary for this project.

But if there will be many requests to resolve my original solution, ask me to make it. Wink Post your request here.

Eliot: you may post this code hack to the Resource center or at least here in a clear format, so others will be able to use without the need to reprogram it. Don't forget to mention the need of changing the links.def.

Best Regards,
Webmaster33

[This message has been edited by webmaster33 (edited January 24, 2000).]
Quote Reply
Re: Passing checkbox values to add_error.html or modify_error.html In reply to
Uh...The codes I provided were actually written by Bobsie originally. I just adapted the codes to your City field. So, it is not my place to post this code hack.

Again, the only way to have values selected based on the previously inputed values is to use the first set of codes I gave you.

There may be some additional codes you can use, but I can't think of any right now.

BTW: I have edited my previous reply, so that the codes will work for other users.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
* Be sure to visit the Resource Center for FAQ's, Modifications and Extra Goodies!!
* Search Forums!
* Say NO to Duplicate Threads. :)
----------------------







Quote Reply
Re: Passing checkbox values to add_error.html or modify_error.html In reply to
I'm glad with your 2nd solution.

You say: "Again, the only way to have values selected based on the previously inputed values is to use the first set of codes I gave you."
I wrote above, there is a possible solution I could write. So the question is not if it is possible, but if it is worth to do it...
Anyway, if there will be some requests I will do it.

Best Regards,
Webmaster33
Quote Reply
Re: Passing checkbox values to add_error.html or modify_error.html In reply to
I don't personally see a need for it. In terms of being worth your time, if it is something that you need for your site...go ahead and do it. I would'nt wait for a poll of other LINKS users to say yea or nah for the Mod.

As Nike says,"Just do it".

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
* Be sure to visit the Resource Center for FAQ's, Modifications and Extra Goodies!!
* Search Forums!
* Say NO to Duplicate Threads. :)
----------------------







Quote Reply
Re: Passing checkbox values to add_error.html or modify_error.html In reply to
 Smile yeah, true Smile