By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,640 Members | 2,077 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,640 IT Pros & Developers. It's quick & easy.

PHP and SELECT Box issues

P: n/a
JT
I have an input form for which I've created a "matrix" for user input.
Basically, the user chooses a radio button and then through javascript, a
select box is displayed to define a value for that radio option, like so:

Choice: (Radio1) type: (select box1)
Choice: (Radio1) type: (select box2)
Choice: (Radio1) type: (select box3)
Choice: (Radio1) type: (select box4)
Choice: (Radio1) type: (select box5)

I know, it looks confusing and is ;)

Now the problem is weird:

After a record is stored, I want to also pull out the data and repopulate
this form with it. I've used the "checked" attribute to define the correct
radio button, and the "selected" attribute to define the selected dropdown
value. This works properly and appears in my HTML properly however when I
make a new choice in the drop-down select box, the value designated as
"selected" always takes precedence when the form is posted.

I really need the user to be able to modify the selct box for the radio
button that has been checked, or to pick a new radio button and then choose
options from that associated select box. For the sake of orderly
presentation, this is the easiest method I have found but for PHP, I need
to override the "selected" value if something new has been chosen.

I'm stumped.

Thanks in advance for any input on this,

-JT

To clarify a bit further, here's an example of the HTML to visualize
things:

<html>
<head>
<title>Select Box problem example.</title><meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/javascript">
<!--
function hide(id){
if (document.getElementById && document.createTextNode){
spans=document.getElementById
('mainform').getElementsByTagName('span');
m=document.getElementById('mainform');
for (i=0;i<spans.length;i++){
m.getElementsByTagName('span')
[i].style.visibility='hidden';
m.getElementsByTagName('p')
[i].style.background='#eee';
m.getElementsByTagName('p')
[i].style.borderColor='#ccc';
}
if(id!='none'){
m.getElementsByTagName('span')
[id].style.visibility='visible';
m.getElementsByTagName('p')
[id].style.background='#ffc';
m.getElementsByTagName('p')[id].style.borderColor='#
000';
}
}
}
//-->
</script>
</head>

<body onload="hide('none')" bgcolor="#FFFFFF" text="#000000">
<form method="post" action="myscript" id="mainform">
<table border="0" cellspacing="2" cellpadding="2" class="text_plain">
<tr valign="top" bgcolor="#E4E4E4">
<td>Resource Type:<br>

<p>
<input type="radio" onfocus="hide(0)" name="ResourceType" value="1"
id="choice1">
<label for="choice1">Organization</label>
<span>&nbsp;&nbsp;&nbsp;&nbsp;<label for="select1">Type:</label>&nbsp;
<select name="ResourceSubType1" id="select1">
<option value="1">Non-profit</option>
<option value="2">Business</option>
<option value="3">Foundation</option>
<option value="4">Government Agency</option>
<option value="5">Network</option>
<option value="6">Professional Association</option>
<option value="7">Academia</option>
</select>
</span></p>
<p>
<input type="radio" onfocus="hide(1)" name="ResourceType" value="2"
id="choice2">
<label for="choice2">Program</label>
<span>&nbsp;&nbsp;&nbsp;&nbsp;<label for="select2">Type:</label>&nbsp;
<select name="ResourceSubType2" id="select2">
<option value="1">Funding</option>
<option value="2">Training</option>
<option value="3">Employment</option>
<option value="4">Document Library</option>
</select>
</span></p>
<p>
<input type="radio" onfocus="hide(2)" name="ResourceType" value="3"
id="choice3">
<label for="choice3">Publication</label>
<span>&nbsp;&nbsp;&nbsp;&nbsp;<label for="select3">Type:</label>&nbsp;
<select name="ResourceSubType3" id="select3">
<option value="1">Book</option>
<option value="2">Journal</option>
<option value="3">Magazine</option>
<option value="4">Newsletter</option>
<option value="5">Internet Newsletter</option>
<option value="6">Directory</option>
<option value="7">Article</option>
<option value="8">Report</option>
</select>
</span></p>
<p>
<input type="radio" onfocus="hide(3)" name="ResourceType" value="4"
id="choice4">
<label for="choice4">Person</label>
<span>&nbsp;&nbsp;&nbsp;&nbsp;<label for="select4">Type:</label>&nbsp;
<select name="ResourceSubType4" id="select4">
<option value="1">Practitioner</option>
<option value="2">Researcher</option>
<option value="3">Journalist</option>
<option value="4">Academic</option>
</select>
</span></p>
<p>
<input type="radio" onfocus="hide(4)" name="ResourceType" value="5"
id="choice5">
<label for="choice5">Website</label>
<span>&nbsp;&nbsp;&nbsp;&nbsp;<label for="select5">Type:</label>&nbsp;
<select name="ResourceSubType5" id="select5">
<option value="1">Document Library</option>
<option value="2">Resources Page</option>
<option value="3">Links Page</option>
<option value="4">Home Page</option>
<option value="5">Program Page</option>
</select>
</span></p>
</td>
</tr>
</table>
</body>
</html>

Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
JT <jo**@adroitdesigners.com> wrote in
news:Xn**************************@68.1.17.6:
I have an input form for which I've created a "matrix" for user input.
Basically, the user chooses a radio button and then through
javascript, a select box is displayed to define a value for that radio
option, like so:

<snipped>

Never mind, it was something really silly that I did in my variable naming.
DOH!

I need a caffeine drip today.

Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.