Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Saving Selection In Drop-down Lists In PHP After Page Reload?


I can't find an answer to my quesiton anywhere.

Given a drop-down list with USA states and other text fields I pass
this information for further processing via PHP. If any of the required

fields is empty, the PHP script would return an error and reload the
form page asking to fill out those fields. All entered information is
saved... except for the drop-down list selection. I tried to write a
Javascript function which is echoed by PHP, but interpolation of PHP
variables in the Javascript section gives a syntax error message in
Javascript.

The PHP script returns, e.g., an "AL" string for Alabama. Of course, I
don't want to write PHP code for each option to make it selected.




View Complete Forum Thread with Replies

Related Forum Messages:
Autopopulating Drop Down Not Saving Unless A Selection Is Made
I have a form that autopopulates and allows user to make changes where necessary. In this form are some drop down menus (hardcoded on the page). All the selections (50 states for example) are there. If I select a state it will then post to the database. If I don't select a state and just leave it as the previously selected state (not change the selection already made by a user) it puts a blank in the database.

Examples:
The <?="$rest_state_pr"?> will pull the state the user selected previously. If I change the slelection it saves the new selection, but if I leave it as the "default" It puts a blank in the database. Code:

View Replies !
Drop Down Menu - Every A Value Of It Is Selected To Reload The Page And Submit That Value.
i have a drop down menu and i want every a value of it is selected to reload the page and submit that value. i'm using something like this: HTML Code:

<select name="menu">
<option selected value="1">GENERAL</option>
<?php
while ($cat = mysql_fetch_array($q)) {
$cid = $cat[0];
$cname = $cat[1];
echo "<option value='$cid'>$cname</option>
";
}

echo "</select>";

i tried using <select name="c" size="1" onChange="MM_jumpMenu('parent',this,0)"> but i got confused so i'm looking for an alternative way..

View Replies !
Drop Down Lists Changing Depending On Other Drop Downs
I want to have a drop down system like this one.  But without the radio buttons.

I want to have 3 drop downs but have no idea how to go about it.  I assume I will need to activate some sort of Javascript on the onChange event of the option drop downs.

View Replies !
Multiple Selection Lists?
i have a mutliple selection list on a form that goes like this

<select name='name' multiple size=6>";
echo "<option value='one'>one";
echo "<option value='two'>two";
echo "<option value='three'>three"; etc it works fine.

BUT how do u call it. For example say i selected option one and three. How do i call that on the next page so that ONE and THREE are stored.

View Replies !
Multiple Lists Selection
I am using a simple registration form that i made with the toolbox, but when I come to a multiple list to choose from (populated from the database) it doesn't work correctly. Of course, out of the multiple items selected only the last one gets inserted.

From what I have read, the selection must be turned into an array then looped for this to work. Is this correct? Next how would I code this to work right. If you let me know which code to post, I will post it.

View Replies !
Multiple Selection Lists &
I have 2 multiple selection lists. I am using javascript so that users can select items from list 1 and move them to list 2. When the user submits the form I need my php to get the values he has/she has in list 2...

I have done printf($_POST['list_2']) and it only shows one value, even when multiple are selected. I read that I need to change it's name to list_2[] but if I add the brackets to the name my javascript quits working.

View Replies !
Keeping Selection Lists
I would like to create 2 single-select drop-down selection boxes on a page

box1 - select academic year from 2001, 2002 , 2003 etc

box2 - select semester from 1, 2, 3 etc

As a result course details for all courses that satisfy these selection values get displayed below the boxes. The boxes remain availabel on the page. The user should be able to re-set these boxes to different values to generate different results. The boxes remain visible on the page. Is this possible ?

View Replies !
Can Header() Do A Div Reload Without A Page Reload (ie Ajax-type)?
I have a display page (displaypage.php) divided into two panes - one for content and one for feedback, referred to in the CSS as contentDiv and feedbackDiv respectively.

When I click on a word in the content pane, I do a PHP/PostgreSQL search for similar words, and the results appear in the feedback pane without a page reload. For this, I am using a very basic Ajax setup Code:

View Replies !
PHP And Drop-down Lists
I want a simple HTML drop-down list like this:

<select name="select_1">
<option name="option_1" value="option_1" selected="true">
<option name="option_2" value="option_2" selected="false">
</select>

to be able to automatically select a value according to a value in a table in the database. For example, if a MySQL table has a field named "field_1", and one of the rows has a value of "option_1" in that field, I want the list (using PHP of course) to automatically select the option name "option_1". How would I go about doing that?

View Replies !
Drop Down Lists
I have used Php to generate a drop down but becos the action of the form is it itself ($_SERVER) I need to echo the value upon submission. Becos this is php generated I'm having problems. This is what the current code looks like:

[PHP]
echo "<select name="branch">
<option value="$variable">$variable</option>
</select>";

View Replies !
Drop Down Lists And Variables
I have a dropdown list with values and I am having trouble getting the value chosen into a variable so that I can use it in an if statement.

View Replies !
Populating Drop Down Lists
Could anyone help me on populating database driven drop down menus. I am trying to populate a second drop down list based on the selection of the first drop down list. I have the first drop down list running. Not sure about getting the second now.

View Replies !
Dpendent Drop Down Lists
I'm making a system for outage reports, I have a field that refers to the outage type.
I want when choosing from the list, for example, POP, all fields hat doesn't refer to POP issues to disappear. I made a demo with a software PHPrunner 4.1 and you can check it out. exapmle: I choose DNS so all feilds refer to POP and other issues should disappear.

View Replies !
Drop Down Lists And Textfields
I've found this is a great place to learn, so hopefully such can happen with the following:
Basically, I'm trying to develop a world market for a text-based game wherein what is available is listed inside a drop-down list, followed by an input box where the user can enter the amount to purchase (up to the quantity amount available) and submit.

Likewise, I've got a drop-down list populated via a MySQL query.  Altogether, the page looks like this:

My question is, how does one associate the input box with the drop-down list, assuming it's possible (which I would assume)?  Currently, it displays correctly, however when one submits via the "Purcase Goods" button, nothing occurs.  I'm not quite sure how to integrate everything coherently; my knowledge is limited in the area of PHP/HTML integration, so any explanation would be kindly appreciated.

I know long streams of code are often unhelpful in pinpointing a problem (or problems), but in the interest of not excluding an element, here's the code of the file in question: ....

View Replies !
Dependent Drop Down Lists
I am building a data entry form in php to insert new records into a mysql database. There are two drop down lists - one for the Botanical name and one for the Common name of each possible plant. I need to make the two lists codependent so that if a user chooses by Botanical name, the correct matching Common name will automatically be selected, and vice versa.

View Replies !
Dynamic Drop Lists For Modify
Hello, I hope this is posted in the correct forum. This is a mix of php and javascript and what I am trying to do combines the two so I hope this is the best place for this post.


I have 2 situations, one when adding an employee and the other is modifying the employee. I have a drop list the holds all of the companies that when you select a company, it changes the droplist of departments to show the available departments for the chosen company. So the dept droplist dynamically changes based off the company you choose. I have this working perfectly. THis is for adding an employee.

My problem I have now is I need to modify the employee and when you first pull up the form with the employee info, it is populated from a mysql query. The droplist for companies is selected to the correct company, however, the droplist for depts is not because the javascript code I have is set to fill the dept list on an onchange event which on page load does not exist.

If they select a different company, my code works fine but when they first hit the page, the dept list is blank because the onchange event has not been kicked off. I realize this is javascript but I am not sure where my changes need to be made.

below is my code for the companies and depts only. I will leave out the other employee info becasue it is irrelavent. I will post what I have so far and hopefully you can guide me in the right direction

Code: ....

View Replies !
Remember Drop Down Box Selection
Is there a better way to do it than i currently am using? Simply echos the value in the selected option that will otherwise be blank, so this makes it impossible for the user to select no input. Code:

View Replies !
Keep Selection Of Drop Down From Menu
Im just working on a enquiry form submission script. When the form is submitted a php scripts checks for empty fields etc. If a empty field is found the for comes back and a error messages is displayed.

When the forms re-appears the fields which werent filled out correctly before stay filled in, simply putting setting the fields 'value' with the $_post variables.

Now this is ok but is there a way so if the users selects a choice from my drop menu the first time that this choice remains when the form re-appears if something else was found to be invalid ??

Hope I explained that ok?

View Replies !
Drop Down Menu Selection Activation
I have a form that is populated with a drop down list and a list box. I
want to be able to automatically populate the list box, whenever a user
selects a new item from the drop down list.

Is there a way of doing this as soon as a new item is selected from the
drop down box? (I'm trying to mimic a rich client interface in a web
browser).

View Replies !
User Selection From Drop Down Menu
I have 2 drop down menus. 1 is to pick a Province and the other is to
pick a trade (plumbng electrical etc)

The user selects which province and then what trade then hits submit
which should list all entries in the table. How would I formulate the
select statment for MySQL to display the results in a webpage. The
variable in my form are $province and $category

View Replies !
Drop Down Boxes Change By Selection
what i'm trying to do is when a user selects a country say UK, all the uk states are displayed in another selection box below BUT if the US is selected all the us states are shown, this is on nion every friends/dating site just curious as to how this is done.

View Replies !
Chain Selection For Drop Down Menu
I have a java script that has a drop down menu where a person select a state and then all the cities for that state show up right next to it.

my problem is that the script it is making the webpage runing slow, or sometimes is telling me that the insternet explorer is running slow because of it and i was wondering if there is a better way to do this with PHP and where should i start

View Replies !
Selection Not Being Made In Drop Down Menu
I have a script that is supposed to select an existing row from a Db, then use that info to edit the row. However, regardless of what I do, the only row that is ever selected is the first row in the Db. Here's the snippet that is supposed to select the row: Code:

View Replies !
Filtering Selection In Multiple Drop Down Boxes
I want to allow a user to conduct a search on a database using multiple drop down boxes.
On the first page they will have a drop box filled with records from field A. Once they select which one they want, a second drop down box will then appear with records from field B which are present for field A (a filter).

What I want though is that the first dwon down box still appears on the second page, but shows the record that the user selected. What is happening now is that when the second page comes up, the first box shows the default selection rather than the selection that the user chose. My code for the drop down boxes is: PHP Code:

View Replies !
Insert The Selection From The Drop Down Menu Into The Database.
I have a drop down menu and I want to insert the selection from the drop down menu into the database. How would I go about this?

View Replies !
Make The Drop Down Box Display The Selection Picked By The User
I have a drop down box that I have coded to have several values. These values are actually snippets for SQL code. how do I make the drop down box display the selection picked by the user after the page is refreshed?

View Replies !
Populate A Drop Down List In A Form On The Basis Of A First Selection
I have developed a form to register a property in a db. The form needs the selection of a country and then based on that selection the selection of regions from the selected country. I have a program which allows selection of a country and then a region but it uses java script which I would like to avoid. I also just wanted one submit button if possible. Code:

View Replies !
Session Var Is Setting ONLY AFTER I Reload Page, Form Var Displays First Page Load
Page1 has a form that calls Page2. The beginning of Page2:
<? php session_start();
$s=$_POST['sSelected'];
session_register("s"); ?>

in the middle of Page2 I have a form varaible:
<?php echo $_POST['stateSelected']; ?>
<?php echo $_SESSION['s']; ?>

The form var displays the first time the page loads. The session var
displays only after reloading the page2.

View Replies !
Saving/Loading Data In Drop-down List
I have a drop-down list with set values.  When there is a corresponding value in my database when the page loads I want the drop-down list to pick the appropriate value from the list.  Instead it always defaults to the first value.  Can anyone give me an example of how to do this?

Also, one time after adding a variable to a classes file this symbol:  started showing up on all of my pages. Has anyone seen this before? I can't find any information on the web about it.

View Replies !
Updating Lists On Page
The problem is that I am displaying all the rows of my table which have the value of the field 'approval' as 0. Now, there are to be 2 buttons next to each row with names "Approve" and "Disapprove".

If you click on approve, then the value of 'approval' for that row becomes 1 and if you click on "Disapprove" , the value of 'approval' becomes -1. How to accomplish it ? as the list being viewed will be changing very often. Code:

View Replies !
Page Reload
I have succesfully created a login page for my site. I have used the PHP_SELF
so that once the user has succesfully logged on the page reloads. Everything
works fine the first time somebody tries to log in but when they revisit, the
log on page is bypassed and it goes straight to the information page. I have a
sneaky suspicion that this is due to the fact that the page is then in their
history of recently visited sites. How can I use PHP to refresh the page
automatically everytime it is requested?

View Replies !
Reload Page On Die
I have a query that seems to fail about one out of five times, resulting in a completely blank page. Here's the query and the call to it (which appears before any HTML is displayed): PHP Code:


$query = "SELECT msg.id, msg.to, msg.from, msg.subject, msg.date,
  u1.first_name as to_first, u1.last_name as to_last,
  u2.first_name as from_first, u2.last_name as from_last
FROM messages msg, userprofiles u1, userprofiles u2
WHERE msg.read = 'n' AND u1.id = msg.to
  AND u2.id = msg.from AND msg.to = '$userid'
ORDER BY msg.date DESC";
$reslt_message = mysql_query($query, $conn) or die(mysql_error());

If there is anything wrong with this query, please let me know. Otherwise, assuming that the query is ok, would it be wrong (or even work at all) to put a header inside the "die" that reloads the page, or would that be bad practice? I can see the possibility of getting an infinite loop, but that could be remedied by adding a variable to the end of the header that would force the code to reload only if it hasn't reloaded yet. if that is clear. When the page crashes, refreshing it works. If I click the link to this page 10 times, it could be the 1st or 10th time that results in a crash, so I'm thinking that the query is ok but it is having trouble processing it or something, which is what led me to think about reloading the page.

View Replies !
Reload Php Page
I am creating (using php) an html page with many links. Clicking on a link open the link as _self. Clicking on the browser back button brings the prv html page (with the links,) but instead of getting it from the cache it will recreate it. how to avoid the re-creation of the php/html page and just to reload it from the cache.

View Replies !
Reload Page
I have a form which is used to add / edit records in a mysql db. This all works fine but after entering a record, and returning to a database view page, a user can hit reload page and a new record is added. Clearly, the previous $_POST vars are still in the system and thus reloading the page runs the same script to add a new record.

View Replies !
Reload This Page
I'm trying to create a cookie on the user's machine that includes the referral url. I then plan to call the data from the cookie in a script that is called on my thank you page to track sales. Why won't the following script work? It's writing "$_SERVER["HTTP_REFERER"]" to the cookie instead of the referrer URL.

<?php $value = '.$_SERVER["HTTP_REFERER"].' setcookie("solvotrack", $value, time()+2592000); /* expire in 30 days */ ?>

View Replies !
Get Two Dropdown Lists Working On A Page
i am trying to get two dropdown lists working on a page. How do i go about this. For example, I have 1 table which holds countries and cities. When a user selects a country in the first dropdown list, i'd like the second dropdownlist populate with a list of cities etc. from my database.

View Replies !
Lists Files In Dir On Page, But Needs To Sort
I have the following code that successfully lists files found in a directory. But, by default it sorts the list by file creation date. How do I make it so that it lists the files in alpha order by filename? Code:

View Replies !
Combo Box Value On Page Reload
I am new to php and mySQL so this is probably something very basic that I'm
missing. Basically, on the page I have 2 combo boxes but 1 of them is not
getting the value passed when the page is reloaded so the database can be
updated. I am echoing the field names passed and the field "theDriver" is
there but it's empty. I've include the code parts where I believe the
problem should be but I'm stumped and I've been trying to solve this for 2
days without success. Would someone mind examing the following code and
tell me what I've done wrong?

Following code constructs the combo box on the page from a MySQL table:
<?PHP
$table = "tblEmployees";
$Link = mysql_connect ($host, $user, $password);

$Query = "select concat(empID,' ',empFirstName,'
',empLastName)
as full_name from $table WHERE empTitle =
'Driver'";
$results = mysql_db_query($database, $Query, $Link);
?>

&nbsp;&nbsp;&nbsp;&nbsp;<b>Driver:</b>
<select name = "theDriver" size="1">
<Option Value=" ">Select One:</option>

<?PHP
for($u=0;$u<mysql_num_rows($results); $u++)
{
$driver=mysql_result($results,$u,'full_name');
?>
<option value="<?PHP echo($ID); ?>"><?
echo($driver); ?></option>
<?PHP
}
?> //end php

</select>

When Page is reloaded the following code is run but the combo box titled
"theDriver" is empty

foreach($_POST as $field => $value)
{
echo $field; //field names from form
echo "; ";
if ($field == "theDriver")
{
echo " - here's the driver for ya: ";
$$field = strip_tags(trim($value));
echo $$field;
$pos = strpos($driver, ";");
echo "<br> the ; is in pos $pos <br>";.......

View Replies !
Page Cache/reload
I have created a facility for users of a site to enter details of property (e.g. location, size etc.). This allows them to upload a picture. Users can also update a picture, adding a new picture to replace an existing one.

My problem is that if a user changes/updates the picture and then views the details the old details are displayed unless the user manually clicks refresh.

I know that this is because IE is storing the page in cache. I have tried the Meta Tags with "no cache" and "expires" but they don't work. I have also tried to get the page to refresh itself on loading, but it either doesn't work at all or keeps refreshing over and over again. Ideally i would like the page to just refresh once and then stop refreshing but there doesn't appear to be any way of doing this.

View Replies !
Refresh To Reload The Page
i was using header("Location: http://test.com/alt.php"); on my php page as a refresh to reload the page as i need to refresh the whole page but hold my sessions i set to rest the forms on it.

but then i had to create a header redirection page in  the website to have get the websites template page on the page i created for the  menu logo  etc. so turning the original page into a redirection to achieve this.  So now my php page is in zen cart and is called in on the first the redirection nut when i try and use a second header location it doesnt work.

View Replies !
Page Reload With An <iframe>
Let me to explain the structure....

filename : api.php

Having an <iframe src="remotehost/index.php"> </iframe>

i have to reload current page api.php after some execution of remotehost/index.php ... I've tried header(); but got formal header error. can we reload current browser url from an iframed code?

View Replies !
Does 'Back' Reload The Page?
I notice that when I click the 'Back' button my previous script runs, i.e, all the php code runs (I previously thought that maybe the previous form displays without the code re-running).
However, I do not get the expected value displayed on my form.

After populating one element in formA with &#3917;' (just any number) and submitting to formB (using POST ---> Redirect --> GET to avoid the 'expired from cache' message) I then click the 'Back' button and the 17 does not appear. In the code below, after clickng 'Back', I see as output from the echo statement that rb_value[0] is, infact, &#3917;' but within the form, the text element named rb_value[0] displays as empty.

Does anyone have suggestions why this might be?

It might have to do with that I do not understand what the 'back' button does. Or maybe with my PRG (post - redirect - get) model.

Here is part of the code:
echo "rb_value[0]=".$rb_value[0]; //After clicking 'Back' I see that rb_value[0] is 17

if (isset($rb_value[0])) {
$rb_val = $rb_value[0];
} else {
$rb_val = 1;
}

$line.= "<td width="20%" valign="center" align="left"> ";

// This element displays as empty instead of the expected 17
$line.= "<input type=text name="rb_value[0]" value="$rb_val" size="25" maxlength=25 </center> "
$line.= "</td> ";


View Replies !
Increment ID In A Page On Reload
I have a page that has an iframe on it, PHP Code:

<iframe src="index.php?u=<?=$ID?>" width="400"></iframe>

What I need to do is on every page reload increment the $ID variable so I load the page

1 time then
$ID = 1

new page reload

$ID = 2


how can I do this?

View Replies !
Reload Same Page With New Query
how would I go about reloading the page with a new query by a click of a link.

right now its loading everything from my table,

SELECT * FROM usr_img;

I want to be able to click a link and have the page reload with,

SELECT * FROM usr_img WHERE img_cat LIKE 'Birds'

Can anyone help me, im still learning php.

View Replies !
Resubmitted With Page Reload
I am using PHP5 and IE 6. I have made a web form. The action attribute of the form is redirecting it to the same page. Like action="index.php" and form name is also index.php . I am using Post method. When the user clicks on the submit button all the post variables are check by the isset function and then only the function to insert data is executed. If the user clicks on submit first time the data is submitted.

View Replies !
Reload The Same Page With A Form After Submit?
I have a page with a form, and the code to process the form answers, I want the same page/form to just reload when the user presses submit. The only function I have found is that location command. PHP Code:

View Replies !
How Do I Force A FRESH RELOAD Of A Page
I've built a few php scripts, but since its reloading the same page I can't get it to refresh the page. I've implemented some expire meta tag...but is there anyway I can try and force it to refresh?

View Replies !
Reload (refresh) Page Within An If Statement
Is there a simple way in php to reload a page coded within an if statement.(see code below)It's very important that the session stays intact. Code:

View Replies !
Session ID Changed Everytime Go To New Page Or Reload.
I'm new member of this group.

I had added new virtual host at my intranet server. The new virtual
host configuration on httpd.conf is similar with the old one.
At the new virtual host, the session id seems changed every
interaction to server (new page or reload).
The old one is fine, the session id keeps at the same string.
Both are at the same server.
I use Apache 2.2.3 (Win32) with PHP 5.2.0.

Tested using code below:
session_start();
echo session_id();

PHP Configuration :
session.save_handler = files
;session.save_path = "/tmp"
session.use_cookies = 1
;session.use_only_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.serialize_handler = php
session.gc_probability = 1
session.gc_divisor = 1000
session.gc_maxlifetime = 1440
session.bug_compat_42 = 0
session.bug_compat_warn = 1
session.referer_check =
session.entropy_length = 0
session.entropy_file =
;session.entropy_length = 16
;session.entropy_file = /dev/urandom
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
session.hash_function = 0
session.hash_bits_per_character = 5

View Replies !
Stop File Reload When Page Is Refreshed
I have a section of PHP code at the beginning of the page that loads a file which the user has specified in the form, on the same page. The problem is that everytime the page is refresh with the refresh button, the file loads. I want the file loading to happen only if the user has pressed the submit buttom.

View Replies !
Reload A Page After Execution Of A Mysql-query In Php
I am aware that this question might involve Javascript and MySQL. So
far I haven´t found a suitable solution in JavaScript ng´s - maybe
becauese php-programmers are more likely to come across the following
problem:

A script on my page relays a quite complicated query to a MySQL-server
with mysql_query(...); The query works fine but takes very long - I
usually have to wait for approx. 30 seconds before the query is
returned from MySQL and the results displayed by php on a webpage.

I´d rather have the results of the query written into a nice textfile
and display a text like "Results are being retrieved" in stead of the
actual results and have the page reloaded a f t e r the textfile has
been updated. The newly loaded page then would obviously first check
whether this very textfile has been updated or not and read out its
contents in case it is has been updated less then let´s say two
minutes ago.

I hope I can make myself understood...:)

My question is: what actual code (I am almost sure it must be
JavaScript and not PHP) does PHP have to generate in order for the page
to reload after the results are retrieved and stored in the textfile?

View Replies !
Reload Outside Page OnClick Of Submit Button
I'm using frames to create a "bookmark-like" page. You can enter a URL and it gets added to my database. I have two frames (leftFrame - to display bookmarks entered and mainFrame to show web page). I want the leftFrame to automatically refresh when the user enters a bookmark. As of now you must physically refresh the page to see the results. Here's my code:

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved