Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

on load populate combo box from php value

Posted on 2008-11-03
3
Medium Priority
?
949 Views
Last Modified: 2012-05-05
here my problem
i have a combobox that populates schools..i want topass the value of this school to a php page that has a combobox init and if the value = a value then it selects that value.

ie

Wittenberg University
University of Louisville
West Liberty State College

user has picked school 2 from previous page. and this value is in $school_pick as "University of Louisville"

how do i get an onload for the combo box to populate the combo box to reflect that please

thank you for any help and code you may propvide
---------------------------------------
i thought i could do this but its not working
<body bgcolor="#ffffff" link="#5e2f2f" text="#000000" vlink="#666666"  onLoad='document.form.School.selectedIndex = "2";'>

<P><strong> College: &nbsp;
    <SELECT name='School' size='1' onChange='reloadCities(this.selectedIndex);' onclick='enableLoft();'>
      <OPTION value='0'></option>
      <OPTION value='Wittenberg University'>Wittenberg University</option>
      <OPTION value='University of Louisville'>University of Louisville</option>
      <OPTION value='West Liberty State College'>West Liberty State College</option>
    </select>
&nbsp; &nbsp;&nbsp; &nbsp;
0
Comment
Question by:Johnny
  • 2
3 Comments
 
LVL 1

Accepted Solution

by:
smilyjf earned 2000 total points
ID: 22874040
Here is one way of doing it:

<?php $selected = 'selected="selected"'; ?>
<SELECT name='School' size='1' onChange='reloadCities(this.selectedIndex);' onclick='enableLoft();'>
  <OPTION value='0'></OPTION>
  <OPTION value='Wittenberg University' <?php if($school_pick == 'Wittenberg University') echo $selected; ?>>Wittenberg University</OPTION>
  <OPTION value='University of Louisville' <?php if($school_pick == 'University of Louisville') echo $selected; ?>>University of Louisville</OPTION>
  <OPTION value='West Liberty State College' <?php if($school_pick == 'West Liberty State College') echo $selected; ?>>West Liberty State College</OPTION>
</SELECT>

Open in new window

0
 

Author Comment

by:Johnny
ID: 22874197
thank you
0
 

Author Closing Comment

by:Johnny
ID: 31512930
thx
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses
Course of the Month21 days, 5 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question