473,326 Members | 2,110 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

How to make text box uneditable?

fieryscream
I have an address form that user fills out
and whent they click same as above it fills out the postal address
how do i make the postal address non editable once the user clicks the same as above box?

Expand|Select|Wrap|Line Numbers
  1. function sameaddress()
  2. {
  3.     document.getElementById("st1").value=document.getElementById("street1").value;
  4.     document.getElementById("st2").value=document.getElementById("street2").value;
  5.     document.getElementById("st3").value=document.getElementById("street3").value;
  6.     document.getElementById("city2").value=document.getElementById("city").value;
  7.     document.getElementById("country2").value=document.getElementById("country1").value;
  8. }
  9.  
HTML

Expand|Select|Wrap|Line Numbers
  1. <p align="left" class="style1">Physical Address:</p>
  2.     <p align="left" class="style1">Street
  3.       <input name="street1" type="text" value="" size="30" id="street1" />
  4.     </p>
  5.     <p align="left"> <span class="style1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  6.           <input name="street2" size="30" maxlength="15" value="" type="text" id="street2" />
  7.     </span></p>
  8.     <p align="left"> <span class="style1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  9.           <input name="street3" size="30" maxlength="15" value="" type="text" id="street3" />
  10.     </span></p>
  11.     <p align="left" class="style1">City 
  12.       &nbsp;&nbsp;&nbsp;
  13.         <input name="city" size="30" maxlength="15" value="" type="text" id="city" />
  14.     </p>
  15.     <p align="left" class="style1">Country
  16.       <select name="country1" id="country1">
  17.           <option>NZ</option>
  18.           <option>AU</option>
  19.           <option>UK</option>
  20.           <option>US</option>
  21.         </select>
  22.     </p>
  23.     <p align="left" class="style1">Postal Address:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  24.         <label>Same as above
  25.           <input name="abovebox" type="checkbox" onClick="sameaddress()" />
  26.       </label>
  27.     </p>
  28.     <p align="left" class="style1">Street
  29.       <input name="st1" type="text" value="" size="30" id="st1" />
  30.     </p>
  31.     <p align="left"> <span class="style1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  32.           <input name="st2" size="30" maxlength="15" value="" type="text" id="st2" />
  33.     </span></p>
  34.     <p align="left"> <span class="style1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  35.           <input name="st3" size="30" maxlength="15" value="" type="text" id="st3" />
  36.     </span></p>
  37.     <p align="left" class="style1">City 
  38.       &nbsp;&nbsp;&nbsp;
  39.         <input name="city2" size="30" maxlength="15" value="" type="text" id="city2" />
  40.     </p>
  41.     <p align="left" class="style1">Country
  42.       <select name="country2" id="country2">
  43.           <option>NZ</option>
  44.           <option>AU</option>
  45.           <option>UK</option>
  46.           <option>US</option>
  47.         </select>
  48.     </p>
Sep 3 '09 #1
5 7461
absolute legend if anyone can get it to work!
Sep 3 '09 #2
Dormilich
8,658 Expert Mod 8TB
what about setting the disabled property?

besides that a label should not include the input element.
Expand|Select|Wrap|Line Numbers
  1. <label for="inp_id">label text for input field</label>
  2. <input id="inp_id" …>
right alignment can als be achieved by CSS (float: right), no need to use spaces (there are more or less complex layouts available, search for form, css, layout)
Sep 3 '09 #3
Frinavale
9,735 Expert Mod 8TB
An example of what Dormilich is talking about:

Expand|Select|Wrap|Line Numbers
  1. function sameaddress()
  2. { document.getElementById("st1").value=document.getElementById("street1").value;
  3.      document.getElementById("st2").value=document.getElementById("street2").value;
  4.   document.getElementById("st3").value=document.getElementById("street3").value;
  5.   document.getElementById("city2").value=document.getElementById("city").value;
  6.   document.getElementById("country2").value=document.getElementById("country1").value;
  7.   document.getElementById("country1").disabled = true;
  8. }
Sep 3 '09 #4
yup cool that was gold!~

how do i make when unchecked then the boxes then become blank again?
Sep 6 '09 #5
Dormilich
8,658 Expert Mod 8TB
set their value to "".

_________
Sep 6 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

16
by: laura | last post by:
Can anyone help me to decide the best way to do this please. I'm writing an intranet and I need to put something like a non-editable scrolling text box on the home page where daily announcements...
8
by: Mike MacSween | last post by:
There doesn't seem to be a way to do this. The Access security model seems to be based around allowing the users to read/alter design of the form (where reading includes editing the data) I want...
5
by: sunilkeswani | last post by:
How do I make an Access DB protected, uneditable/deleteable without the use of any password? Please help Regards
1
by: jaishu | last post by:
Hi, how do i make the fields in my form uneditable(cannot delete or add but can copy a field from form), i tried setting the properties..allow additions deletions by setting it to no, but even...
4
by: Steve Kershaw | last post by:
Hi, I have a gridview with an UpdateQuery() that's fired when the user edits/updates a row. The problem lies in the fact that every cell in the edited row shows up as editable even though one...
4
by: manishamca | last post by:
how to make the textbox uneditable when we click a button. I want to make the textbox uneditable when we click a button.plz help me. thanks in advance.
5
by: manishamca | last post by:
i want to make the chociebox uneditable that is the option selected shuld not change after we click a button... plz help me. Thanx in advance
2
by: premMS143 | last post by:
Hi Everybody, I've created a power point presentation which contains COmputer Fundamentals. Anyone with basic computer knowledge can learn MS-Office with the help of this presentation. That one...
4
by: premMS143 | last post by:
Could anybody help me how to make PPT file Uneditable, so that users can only read that PPT file. I already converted it to pps & make a package usoing 'Package for CD". But still it can be...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.