Hi,
I built a form in php that contains some check boxes and drop-down boxes and a Add button. What I want to do is manipulating the check box state (checked and uncheked state) in order to disable button and other elemnets form.
My question is how can I manipulate the formm element with out submiting it. The codeis display below.
[HTML]<input name="cars id="cars" type="checkbox" value="cars"> Airplanes
, I am
<select name="jetsExper ience" style="width:15 0px">
<option value="1" selected="selec ted">Novice</option>
<option value="2">Inter midate</option>
<option value="3">Exper t</option>
</select>
Driver, own the following car:
<select name="manufactu re" style="width:15 0px">
<option value="Fiat">Fi at</option>
<option value="Honda">H onda</option>
<option selected value="Volvo">V olvo</option>
</select>
<select name="model" style="width:15 0px">>
<option value="130">130 </option>
<option value="140">140 </option>
<option selected value="150">150 </option>
<option value=""></option>
</select>
<input type="button" name="groovybtn 1" class="addButto n" value="ADD" title=""> <br />[/HTML]
4 2486
A form is always a HTML form, not a PHP forum. PHP just generates it.
When would you like to manipulate these elements: at the moment an item is selected or when the add button is clicked, or how else? without submitting.
I guess that you can achieve what you want using JavaScript, since you do not want a submit.
Ronald
A form is always a HTML form, not a PHP forum. PHP just generates it.
When would you like to manipulate these elements: at the moment an item is selected or when the add button is clicked, or how else? without submitting.
I guess that you can achieve what you want using JavaScript, since you do not want a submit.
Ronald
Hi ronald,
1. The issue is that I am creating a PHP register page, since I don't want that the registration information will go from the client not iencrypted(I ran it on the server). So The HTML above is a part of the php file registration form. Can it be done. in the beginig of the PHP file their is a php section that process the sent inofrmation and after word there is a HTML form document.
2. Can I send throught the same php page in the html part a query to the DB and populte a dropdown list with the quesry result. I run all the calculation on the server.
Yes, you can populate your HTML drop downs etc. using PHP.
Something like e.g.[php]echo '<select name="mysel">';
while ($row=mysql_fet ch_assoc($resul t)) {
echo '<option value="'.$row['item'].'">'.$row['item'].'</option>';
}
echo '</select>';[/php]But it would be a lot easier for us to see what code you are talking about and show what you have done so far.
Ronald
Thanks ronald but I already figure it out my self. Now I have a different problem that I amworking onit. If I select a value from the list and want to manipulated it for building second list that depend on the slection of the first list before the form is sunbmitted. Any clue howit can be done.
Here is the code that I have: -
<?php
-
-
/*
-
- Function to return the Country list as an array
-
- The array can be generated from a database resultset
-
*/
-
function getCountryList()
-
{
-
// Country List array
-
$countryList = array (
-
'1' => 'Bangladesh',
-
'2' => 'USA',
-
'3' => 'UK'
-
);
-
-
return $countryList;
-
}
-
-
/*
-
- Function to return the City list as an array
-
- Country ID is used to generate the city list
-
*/
-
function getCityList($countryId)
-
{
-
// City list array
-
// First key of the array is the Country ID, which holds an array of City list
-
$cityList = array (
-
'1' => array ('Dhaka', 'Chittagong', 'What else'),
-
'3' => array ('London', 'Cannot Remember'),
-
'2' => array ('Washington', 'N.Y.', 'etc')
-
);
-
-
return $cityList[$countryId];
-
}
-
?>
-
-
<form action="" name="populate">
-
-
<?php
-
// Retrieving the country list
-
$countryList = getCountryList();
-
if (!empty($countryList))
-
{
-
// Generating the country drop down menu
-
echo "<select onChange='reload(this.form)' name='countryList'>";
-
foreach ($countryList as $key => $value)
-
{
-
echo "<option value='$key'";
-
-
if ($countryId == $key)
-
echo "selected";
-
-
echo ">$value</option>";
-
}
-
echo "</select>";
-
}
-
// Setting the variable if the country is selected for its city list
-
//@$countryId = $_GET['countryId'];
-
// I want to build the city list based on the selection of the countryId
-
-
// Retrieving the city list if a country is selected
-
$cityList = ($countryId) ? getCityList($countryId) : null;
-
-
-
if (!empty($cityList))
-
{
-
// Generating the city drop down menu if a country is selected
-
echo "<select name='cityList'>";
-
foreach ($cityList as $key => $value)
-
{
-
echo "<option value='$key'>$value</option>";
-
}
-
echo "</select>";
-
}
-
-
?>
-
</form>
-
-
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Anna |
last post by:
Hi all.
I have a javascript function that loops throught all text boxes inside
a form:
var elems = document.formName.elements;
for(i = 0; i < elems.length; i++) {
if(elems.type && elems.type.toLowerCase()=="text")
do something
}
|
by: Randell D. |
last post by:
HELP!
I am determined to stick with this... I'm getting there... for those who
haven't read my earlier posts, I'm createing what should be a simple
function that I can call to check that required fields in a form have
values. I'm writing the values to the client using document.write only so
that I can confirm that the values are there to...
|
by: Amir Hardon |
last post by:
I'm new to DOM and can't figure out this thing:
I'm trying to add a row to a table with a form field in one
of it's cells, but if I'm appending the field to a form
it gets out of the table. Can some one tell me what I'm doing wrong?
it looks like this:
var tbl=document.tbl;
var frm=document.frm;
var newcell=document.createElement("TD");
|
by: Asad |
last post by:
I have a form on a page that has several textareas, and textboxes
inside a table (so the table containing the textboxes is also inside
the FORM tag).
I want to replace the textareas with simple text instead. But I want
to keep the format of my page EXACTLY the same. However, the problem
is that ...
1) Javascript won't let me create say a...
|
by: pizzy |
last post by:
INTRO: I tried to clean it up for easy reading. I hope I didn't make
any mistakes.
PROBLEM: WOW, this is some crazy sh!t. I can't get my checkbox (see
"TAGSELECTED") to print my textboxes (see "TAG#") when more than 1
number (see "VLANS") is inputed into my form.
QUESTION: How do I make my dynamic form have a dynamic input box(which
is...
| |
by: Markus Ernst |
last post by:
Hi
I have a validation problem with a form and nested divs. I understand what
the problem is, but I don't see how to fix it. This is my normal page
structure, and it validates:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
|
by: jingalls |
last post by:
I'm trying to modify a form so that when a user clicks a checkbox for a
shorter version of the form, it will replace swap the default (long)
form elements with the short version of elements, so that only the
version that is selected will have its element values passed on to the
next page.
Currently I have two div areas set up with ids as...
|
by: ashok.dhananjeyan |
last post by:
Hi,
Actually , I wrote one javascript to retrieve the name of the form in
one particular page.
what i did in this page is,
<script>
function checkbutton()
{
|
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...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
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...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
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...
|
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...
|
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: 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...
| |