when I click the number..

K

kirke

Hi,
I have a tricky problem..

I printed out several numbers. For example,

for ($i=0:$i<$k;$i++)
printf("%s",$number[$i]);


Then, numbers are printed out. e.g.,
1
2
3
4
5
6

When I click the number I want to receive the number in other text box
which is in out of for-loop.
So I put add buttons in each row.

<input type="text", name="Vehicle">

for ($i=0:$i<$k;$i++)
<input type="text" , name="veh" , value=" <?php echo $number[$i]; ?>">
<input type="button" name="button1" value="add" onclick="return
checkMultiple()"/>

<script language="javascript" type="text/javascript">
function checkMultiple(){
var form1 = document.forms["t2_form"];
var text1 = form1.elements["veh"];
var button1 = form1.elements["button1"];
var list1 = form1.elements["Vehicle"];
if(text1.value == "") return;
list1.value = text1.value;
text1.focus();
}
</script>

however, as you guess, since all text boses names are "veh" and add
buttons are "button1"
So, it doesn't work.
How can I do seperately?????
Or can I do this job without using "input text box"?
Thx.!!
 
A

ASM

kirke a écrit :
When I click the number I want to receive the number in other text box
which is in out of for-loop.
So I put add buttons in each row.

row of what ?

Try this :

<input type="text", name="Vehicle">

<?
for ($i=0;$i<$k;$i++)
{
echo $number[$i]; ?> :
<input type="radio" name="button1" value="<?= $i ?>"
onclick="return checkMultiple()"/>
<?
}
?>
<script type="text/javascript">
function checkMultiple(){
var form1 = document.forms["t2_form"];
var list1 = form1.elements["Vehicle"];
var button1 = form1.elements["button1"];
for(var i=0; i<button1.length; i++)
if(button1.checked)
{
if(button1.value == "") return;
list1.value = button1.value;
text1.focus();
}
}
</script>


Or also :

<input type="text", name="Vehicle">
<select name="choice"
onchange="var k = this.options.selectedIndex;
this.form['Vehicule'].value = this.options[k].value;">
<?
for ($i=0;$i<$k;$i++)
print("<option value=\"$i\">$number[$i]</option>
");
?>
</select>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,265
Latest member
TodLarocca

Latest Threads

Top