Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Form inside a form? JS form?

Form inside a form? JS form?
Thread Tools
Mac Elite
Join Date: Jan 2001
Status: Offline
Reply With Quote
Oct 11, 2003, 04:30 AM
 
Does having a form inside another form work? If yes, is it not proper coding?

I mean something like this:
Code:
formtag html... formtag html.... endformtag html... endformtag
I need this because if the user presses enter after this one particular textbox, I don't want the whole page to get submited.

Also, is there a way to have the form action run javascript code?


Thanks!


P.S. this code function still takes away the form tag, which is why i wrote the code like that
     
Mac Elite
Join Date: Dec 2001
Location: Atlanta, GA, USA
Status: Offline
Reply With Quote
Oct 11, 2003, 08:51 AM
 
Originally posted by timmerk:
Does having a form inside another form work? If yes, is it not proper coding?

I mean something like this:
Code:
formtag html... formtag html.... endformtag html... endformtag
I need this because if the user presses enter after this one particular textbox, I don't want the whole page to get submited.

Also, is there a way to have the form action run javascript code?


Thanks!


P.S. this code function still takes away the form tag, which is why i wrote the code like that
There is a javascript callback on a submit button called "onSubmit" . You can return true/false and it will either submit the form or not based on your wish.
Mac Pro 2x 2.66 GHz Dual core, Apple TV 160GB, two Windows XP PCs
     
Fresh-Faced Recruit
Join Date: Apr 2001
Location: Atlanta, GA, USA
Status: Offline
Reply With Quote
Oct 11, 2003, 12:42 PM
 
No, you can't have a form inside a form, the first formtag will take precedence. But you can use other logic to see if they leave a form earlier than you want. If there is an actual submit button there it's simple, you just name your submit buttons. If you don't then you'll have to check what fields have data in them to see where they finished off in the form.

Hope that helps,

varcos
     
timmerk  (op)
Mac Elite
Join Date: Jan 2001
Status: Offline
Reply With Quote
Oct 11, 2003, 05:27 PM
 
Ok, thanks for your replies. Any idea how do use onSubmit with this:

http://www.u.arizona.edu/~karlt/admin.php

There is the page I'm working on. In the part where you can add IPs is what I'm talking about. If the user enters an IP to add, but presses "return" instead of clicking add, I don't want the form being submited - even to check after. I need a javascript solution or form inside a form solution, which is not possible, so I'm told.

Ideally, presses "Return" in the add_ip textfield will run the same function as clicking the Add link does, all without ever submiting anything.

Thanks!
     
timmerk  (op)
Mac Elite
Join Date: Jan 2001
Status: Offline
Reply With Quote
Oct 13, 2003, 12:27 AM
 
bump
     
Dedicated MacNNer
Join Date: Feb 2001
Location: Manhattan
Status: Offline
Reply With Quote
Oct 13, 2003, 07:23 AM
 
try something like this (i have not tested this):

Code:
<input name="add_ip" type="text" id="add_ip" size="16" maxlength="15" onchange="addIP(this.value);">
     
timmerk  (op)
Mac Elite
Join Date: Jan 2001
Status: Offline
Reply With Quote
Oct 13, 2003, 03:14 PM
 
That code half works - it adds the ip to the list box, but then the whole page gets submited after that as well. Any ideas?

Thanks!
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 07:15 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2