Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to control forms in a form

Status
Not open for further replies.

doyle9732

Programmer
Apr 12, 2002
185
CA
I have a submit page that has the option of submitting a new item in the main submit page. To keep it simple. Let's suppose the main submit page is submitting a fruit and vegetable. But in the main page I give you to opportunity to add a fruit to the existing list. But there's no session variable or anything to capture the information on the main form until you submit it. Can I somehow name a form and connect it to the closing form tag so that I can submit information and then submit the whole form?

clear as mud?

thanks!
Stephanie
 
If I understand you correctly, you have a drop down list of fruits. You want the user to have the ability to add a fruit, if it is not found in the drop down list. Correct?

I would just add a text field (maybe "otherFruit"). Then on your action page, check the value of "otherFruit". If it's not an empty string, use it. Otherwise, use the value of the select box.

<cfif len(trim(form.otherFruit))>
... use the value of otherFruit
<cfelse>
... use the select box value
</cfif>

Hope this helps...
 
Maybe my fruit example wasn't such a good one.

I'd like to have a submit form in the overall submit form because the 'new fruit' they add also has additional information, about 6 input fields that will all be added to a table in the database.

Is there away of having forms embedded?

Thanks!
Stephanie
 
why not have a link that sends the user to a page where they can add a new 'fruit', and the 6 pieces of data that go with it. submit this to the database. then, next time the main fruit submit page is loaded, the new fruit that was added wil show up. Maybe we are still confused?
 
I don't think you can &quot;embed&quot; forms. Maybe someone else has a better solution, but here's a few thoughts.

I would do as I stated earlier, maybe with the addition of a check box that says, &quot;Other Fruit&quot;. That way, you only have to check for the existence of the check box value on your action page (the page the form submits to).

On your action page, if the checkbox was checked, use the &quot;newFruit&quot; fields, if it hasn't, use the one from the select box.

Hope this points you in the right direction. You could probably use Javascript, maybe combined with a popup box to add a new fruit, but that's beyond a simple reply.

<!--- Form Page --->
<form action=&quot;actionPage.cfm&quot; method=&quot;post&quot;>

Choose a fruit:
<select name=&quot;fruit&quot; size=&quot;1&quot;>
<option value=&quot;orange&quot;>Orange</option>
....
</select>

<hr />

<input type=&quot;checkbox&quot; name=&quot;newFruit&quot; value=&quot;1&quot; /> Add a New Fruit

<br />

Fruit Name: <input type=&quot;text&quot; name=&quot;newFruitName&quot; /><br />
Fruit Cost: <input type=&quot;text&quot; name=&quot;newFruitCost&quot; /><br />
Fruit In Stock: <input type=&quot;text&quot; name=&quot;newFruitInStock&quot; />

<br />

<input type=&quot;submit&quot; value=&quot;Submit&quot; />

</form>


<!--- Action Page --->
<cfif isDefined(&quot;form.newFruit&quot;)>
- insert new fruit into database using the values from the form
- do whatever else needs to be done
<cfelse>
use the fruit selected from the drop down menu
</cfif>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top