PDA

View Full Version : Combining values from various form components into one textfield


moonsyi
10-29-2010, 03:51 AM
i have been googling for the answer and none of them seems to be fit in my problem. in my form i have 2 drop down list and one textfield, and i wish to combine the values of them into a single read-only textfield.

this is the sort of the basic idea of my form. anyone has any idea?

<form id="form1" name="form1" method="post" action="">
<p>&nbsp;</p>
<p>
<label for="parts">PARTS</label>
<select name="parts" id="parts">
<option value="01">SEAL FACE</option>
<option value="20">SHAFT SLEEVE</option>
</select>
<br />
<label for="material">MATERIAL</label>
<select name="material" id="material">
<option value="SS6">STAINLESS STEEL</option>
<option value="CR1">CARBON</option>
<option value="DD1">DIAMOND</option>
<option value="ZZZ">OTHERS</option>
</select>
<br />
<label for="running">RUNNING NO.</label>
<input type="text" name="running" id="running" />
</p>
<p>
<label for="new_partcode">NEW PART CODE</label>
<input type="text" name="new_partcode" id="new_partcode" />
</p>
</form>

edbr
10-29-2010, 04:20 AM
possibly javascript but why do you need this?on submit these will be passes as post values and you can then join them if you want

moonsyi
10-29-2010, 04:26 AM
i am making a new partcode generator that combines the value of the 3 above (parts+material+running num.), the values from the parts and material dropdown list combined with the running number will produce the said partcode. i don't know if this can be done automatically to the textfield (preview the partcode), or i would need a button to to fire the combination function and preview the partcode into the textfield. from the textfield it will be stored into the d.base...

edbr
10-29-2010, 04:48 AM
possibly a javascript function could collect the values onBlur otherwise it would have to be done after submit the if you use serverside

moonsyi
10-29-2010, 05:16 AM
i'm not really familiar with javascript as well the dreamweaver unfortunately, may i know the js function to collect the values?

moonsyi
11-01-2010, 02:25 AM
possibly a javascript function could collect the values onBlur otherwise it would have to be done after submit the if you use serverside

ed, i think i caught your drift now, and i think i wanna concatenate them in PHP script. thanks.