realjumper Posted June 8, 2008 Share Posted June 8, 2008 Hi, My form has several radio buttons and text area's. The user is only able to enter text into one area, which is determined by which radio button is clicked. I have this sorted out and working just fine. However, it would be very nice to set the focus on the appropriate text area as well, to help the user. I can't seem to get this working. Here is a sample of my code.... <table class="fbt" border="0"> <tr> <td><b>Cash: </b></td> <td> <input type="radio" name="finance_type" value="Cash" onclick="document.requisition.order_num.disabled = true;document.requisition.payable_to.disabled = true"></td> </tr> <tr> <td><b>Order Form: </b></td> <td> <input type="radio" name="finance_type" value="Order Form" onclick="document.requisition.order_num.disabled = false;document.requisition.payable_to.disabled = true"> Order Number (if known): <span style="margin-left:10px;"><input type="text" class="input-box" size="40" name="order_num" disabled="disabled"></span></td> </tr> <tr> <td><b>Cheque: </b></td> <td> <input type="radio" name="finance_type" value="Cheque" onclick="document.requisition.order_num.disabled = true;document.requisition.payable_to.disabled = false"> Payable to: <span style="margin-left:89px;"><input type="text" class="input-box" size="40" name="payable_to" disabled="disabled"></span></td> </tr> </table> So what's happening here is this: If the user clicks the 'Cheque' radio button, then he may enter data into the 'payable_to' field. If the user clicks the 'Order Form' radio button, then he may enter data into the 'order_num' field. You can see that I have disabled the fields so that a user cannot (for example) enter data into the 'order_num' field unless they have clicked the 'Order Form' radio button. The same goes for the 'Cheque' radio button and the 'apyable_to' field. What I want to do is to go a step further and set the focus on the appropriate field. So if the user clicks the 'Cheque' field radio button, the focus is set to the 'payable_to' field. If the user clicks the 'Order Form' radio button, the focus is set to the 'order_num' field. I am on the brink of solving this ( I think) but I need some help for this last step please. Many thanks Quote Link to comment Share on other sites More sharing options...
realjumper Posted June 8, 2008 Author Share Posted June 8, 2008 Never mind.....I got it! Always seem to get the answer after I ask lol!! <td><b>Order Form: </b></td> <td> <input type="radio" name="finance_type" value="Order Form" onclick="document.requisition.order_num.disabled = false;document.requisition.order_num.focus();document.requisition.payable_to.disabled = true"> Order Number (if known): <span style="margin-left:10px;"><input type="text" class="input-box" size="40" name="order_num" disabled="disabled"></span></td> </tr> <tr> <td><b>Cheque: </b></td> <td> <input type="radio" name="finance_type" value="Cheque" onclick="document.requisition.order_num.disabled = true;document.requisition.payable_to.disabled = false;document.requisition.payable_to.focus()"> Payable to: <span style="margin-left:89px;"><input type="text" class="input-box" size="40" name="payable_to" disabled="disabled"></span></td> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.