News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Javascript Forms within Forms

Started by Les Mackenzie, December 15, 2003, 04:43:02 PM

Previous topic - Next topic

Les Mackenzie

I have an application that requires a javascript form that looks like this embedded in the page via include();

//include name(javanav.php)
<form action="<? $PHP_SELF; ?>" method="post" name="selectone">
<td width="15%" style="padding-left: 10; padding-right: 10; padding-top:2; padding-bottom:2" align="left" height="19">
    <!--Ph_ID drop down menu-->
    <select size="1" name="phid" onChange='this.form.submit()'>
    <?
    // GET Pharmacy ID's by Territory
    $query = "SELECT Ph_ID, Pharmacy_Name FROM pharmacies WHERE terr_ID='$SESSION_TERR_ID'";
    $result = mysql_db_query($database, $query, $connection) or die ("Error in query: $query. " . mysql_error());
    while (list($Ph_ID, $Pharmacy_Name) = mysql_fetch_row($result))
        {
            echo "<option value='$Ph_ID'>$Ph_ID</option>";
        }
    ?>        </select></td>


When I select this "nifty" dropdown it propogates all of the neccessary information to the rest of the form based on Ph_ID# but it is supposed to operate within the larger picture.

One the information is propogated I want to add additional info and submit it to the database all at once. The submit seems to want to operate under the same principal as <form action="<? $PHP_SELF; ?>" method="post"> and not <form action="add_sum.php" method="post">

I've closed the form tags in html but still the inner form seems to override the outer one. Can forms be used in the way I've specified or is there another way to do this?

All help appreciated :|
BLOGS SUCK! - HERE READ MINE

Please Note:  Arguing on the internet is like running in the Special Olympics...  Even if you win you're still retarded.

[Unknown]

$PHP_SELF (or rather, $_SERVER['PHP_SELF']) is the currently running SCRIPT not file.  If you include something, it's not the file you included, but the file you were in in the first place.

-[Unknown]

Les Mackenzie

I've removed the include and made the code one big chunk but still I seem to have the problem...

The "this.form.submit()" function within the form seems to be overriding all other forms on the page. Is there a way to isolate this form without writing a function?  The page includes a submit button that will run a script to insert data into the database after the page is filled with content but as I said the above function seems to override everything else ???

I'm not very good at javascript (novice at best). 
BLOGS SUCK! - HERE READ MINE

Please Note:  Arguing on the internet is like running in the Special Olympics...  Even if you win you're still retarded.

Jack.R.Abbit™

it is doing just what you told it to.  "On change... submit".  If you want the change in the selection element to fill in the rest of the form, you will need to write a javascript function to do it.  I don't see any way around.

http://www.javascriptkit.com/  <= One of my favorite javascript resources

Les Mackenzie

Thanks J.  I was hoping there was a javascript predefined function like this.form.post() or something.  Thanks for the resources and the clarity  :D
BLOGS SUCK! - HERE READ MINE

Please Note:  Arguing on the internet is like running in the Special Olympics...  Even if you win you're still retarded.

Les Mackenzie

Oh ya...  thanks to you too [Unk]  :P
BLOGS SUCK! - HERE READ MINE

Please Note:  Arguing on the internet is like running in the Special Olympics...  Even if you win you're still retarded.

Advertisement: