Hi,
I'am triyng to create a form where i have 2 comboBox and 2 textbox, when the selection changes on the first combo , the content of second also changes. i have to use onchange=form.s ubmit()
the problem is, i want to have a button to finish the selection and save all the data to a database, but if i have diferent forms, i will not get the last change on the text boxs, only th last change when i changed the combobox.
Using the same form how can i know if it was the button pressed or the combochange that executed the submit ??
here's an example
Could you help me
Thx
2 22283
Hi,
i want to make a menu with 2 combos and 2 text boxes. when 1st combo changes, second combo is updated automatically (using onchange.submit ()), and i have 2 more text boxes.
The problem is, i want to have a submit button, and when pressed it will execute a function in the index.php with the last changes from all the 4 inputs.
- i have triyed in the same form, but this way, i dont know if the submit was executed by the button or by the change in the 1st combo box(onchange.su bmit()).
- if i use another form i lose last data from text boxes
Can someone help me !!!
Here's the problem source.
thanks in advance
//##############
//Index.php
//##############
include "funcs.php" ;
print "INDEX state ".$state."<br>" ;
print "INDEX city ".$city."<b r>";
print "INDEX date ".$date."<b r>";
print "INDEX phone ".$phone."<br>" ;
if ($state=="")$st ate="stateA";//1;
if ($savebutton==' 1')print "Function to save";
$savebutton=0;
ask_data($state ,$city,$date,$p hone);
//############
//FUNCS.PHP
//#############
function ask_data($state ,$city,$date,$p hone)
{
$states=array(' stateA','stateB ');
$city1=array("S tateAcity1","St ateAcity2","Sta teAcity3");
$city2=array("S tateBcity1","St ateBcity2","Sta teBcity3");
?>
<table width="735" border="1" cellspacing="0" cellpadding="0" >
<tr>
<td align=center><b r>State 
<form method="POST" enctype='applic ation/x-www-form-urlencoded' style="word-spacing: 0; margin-top: 0; margin-bottom: 0" name="formstate " action="index.p hp">
<select name="state" onchange=formst ate.submit() >
<? for ($i=0;$i<sizeof ($states);$i++)
if ($state==$state s[$i])
print "<option selected value=".$states[$i].">".$states[$i]."</option>";
else
print "<option value=".$states[$i].">".$states[$i]."</option>";
?>
<input type='hidden' name='city' value=<?echo $city?>>
<input type='hidden' name='phone' value=<?echo $phone?>>
<input type='hidden' name='date' value=<?echo $date?>>
</select>
</td>
<tr>
<td align=center>
City <br>
<?
if ($state=='state A') $citys=$city1;
else $citys=$city2;
?>
<select name="city" onchange=formst ate.submit() >
<?
for ($i=0;$i<sizeof ($citys);$i++)
if ($city==$citys[$i])
print "<option selected value=".$citys[$i].">".$citys[$i]."</option>";
else
print "<option value=".$citys[$i].">".$citys[$i]."</option>";
?>
<input type='hidden' name='phone' value=<?echo $phone?>>
<input type='hidden' name='date' value=<?echo $date?>>
</select>
</td>
<tr>
<tr>
</table>
<table width="735" border="1" cellspacing="0" cellpadding="0" >
<tr>
<td align=center><b r>Phone <br ><input type="text" size=10 MAXLENGTH=10 name="phone" value=<? echo $phone; ?> >
</td>
<tr>
<td align=center><b r>Date <br> <input type="text" size=6 MAXLENGTH=5 name="date" value=<? echo $date; ?> >
</td>
</table>
</form>
<form>
<?
print "FORM2 state ".$state."<br>" ;
print "FORM2 city ".$city."<b r>";
print "FORM2 date ".$date."<b r>";
print "FORM2 phone ".$phone."<br>" ;
?>
<input type='hidden' name='state' value=<?echo $state?>>
<input type='hidden' name='city' value=<?echo $city?>>
<input type='hidden' name='date' value=<?echo $date?>>
<input type='hidden' name='phone' value=<?echo $phone?>>
<input type='hidden' name='savebutto n' value='1'>
<input type='submit' name='save' value='Save Data'>
</form>
<?
}
?>
I didn't understand much of what you said and your code is a mess. Stop using short tags and put double quotes around parameter values. But getting to your question, which I hope I got right and I hope this is what you need:
*** FILE.PHP
[PHP]<?php
if (!isset($_REQUE ST['submit_btn']))
{
if (isset($_REQUES T['user_opt']))
echo 'The option previously selected is: '.$_REQUEST['user_opt'];
?>
<form method="post" action="file.ph p" name="dumbform" >
<select name="user_opt" onchange="dumbf orm.submit()">
<option value="1">one</option>
<option value="2">two</option>
<option value="3">three </option>
</select>
<input type="submit" name="submit_bt n">
</form>
<?php
} else {
DoSomething();
?>
You have pressed the submit button.<br />
user_opt = <?php echo $_REQUEST['user_opt']; ?>
<?php
}
?>[/PHP]
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: S Wickes |
last post by:
I've become suspicious that the submit button does not count as an
onChange event in some browsers. Here's why.
I have a form with many textareas. After you click submit, I only
update the database with those textareas which were changed.
Thus, each textarea has an onChange event which marks that box as
changed.
BUT! Some users report that, if they don't take their cursor out of
|
by: Andy Goldstein |
last post by:
I have a table where all the TRs have an onClick handler registered.
One (and only one) of the rows has 2 text input boxes, where each
textbox has an onChange handler registered. Both the onClick and
onChange handlers do some minor manipulation of form data (although
they work on different form elements). If the onChange event fires, I
need the form to be submitted. If the onClick event fires for a TR, I
also need the form to be...
|
by: charlie_M |
last post by:
I figured out via various help from this forum...
EXAMPLE:
onClick="document.forms.MYBUTTON.value='SIMPLE';document.forms.submit()"
In my CGI I see "MYBUTTON" = "SIMPLE"
and this works fine.... except that the element MYBUTTON must exist as
a hidden field.
|
by: Pascal Batzli Jr |
last post by:
Hello,
I have a strange situation happening on the code below. When I first
load the page, as I change any of the three combo boxes I have created,
the onchange event is fired and the form should be submitted, but it
isn't for some weird reason. However, after I press the ok button, it
submits the form, and then the combo boxes start working normally. In
IE, everything works fine.
I appreciate any help. Thank you.
<html>
|
by: Gayathri |
last post by:
Please find the pasted html,
<html>
<script language="JavaScript" src="cal.js"></script><!-- Date only with
year scrolling -->
</head>
<BODY onLoad="showDetails()">
<script language="javascript">
function validatePage(){
| |
by: somaskarthic |
last post by:
Hi
In my php code , i dynamically created table rows on button click event.
Each row contain 3 selectboxes, 7 checkboxes . On each click of these elements i need to submit the form and save the data to database. After each submit , i need to display the previous added details (with some checkboxes checked and some others unchecked ..) and one new row for next updation.
Here i need to collect all values submitted in the php page.
There i...
|
by: Greg Scharlemann |
last post by:
I have some php code to handle the following form is submitted, but
because there are two places the form submits I get an error. If the
drop down changes, the php code will grow the number of city/state
combinations, if the button is clicked the data is added to the
database. Perhaps there is a better way to grow the number of
city/state combinations while still retaining any text previously typed
into the input boxes?
Thanks for...
|
by: rynato |
last post by:
I ran into an interesting problem while working on a form:
I have a drop down list (think <form><select><option>...) of 'open
sessions' which a user can choose from to continue entering data.
There is a small bit of javascript which, when the 'onChange' event
occurs, triggers a 'submit' which reloads the page and displays the
stored values for that session using a session ID variable named,
'$existingSessions'.
Even though the form's...
|
by: white lightning |
last post by:
How to have <select onchange="this.form.submit()"and also a Submit
button on one form?
I have something like this:
<form action="<?php $_SERVER; ?>" method="post"
enctype="multipart/form-data" name="form1">
<select onchange="this.form.submit();" name="prod">
<option value="">Select product</option>
<option value="12">abc</option>
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |