SitePoint Sponsor |
|
User Tag List
Results 1 to 5 of 5
Thread: text changing
-
Jun 1, 2007, 10:23 #1
- Join Date
- Jun 2002
- Location
- Buenos Aires, Argentina
- Posts
- 361
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
text changing
When list-field changes, it should automatically change some text.
HTML Code:<select name="part" class="input_text"> <option value="1"> Motor </option> <option value="2"> Steel </option> <option value="3"> Glass </option> </select> <p>Price for each [part] is : 20 </p>
My SOHO: http://www.contactopuro.com.ar
-
Jun 1, 2007, 10:56 #2
- Join Date
- Feb 2003
- Location
- Knoxville, TN
- Posts
- 531
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
you'll wanna do something like this...
javascript
Code:function changeText(menu) { document.getElementById("change-this").innerHTML = menu.options[menu.selectedIndex].innerHTML; }
Code:<select name="part" class="input_text" onchange="changeText(this);"> <option value="1"> Motor </option> <option value="2"> Steel </option> <option value="3"> Glass </option> </select> <p>Price for each <span id="change-this">whatever</span> is : 20 </p>
-
Jun 1, 2007, 11:55 #3
- Join Date
- Jun 2002
- Location
- Buenos Aires, Argentina
- Posts
- 361
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Excellent... now, how can I make this function to be active from the begining, at no change event? Eg: If at the beginning it's selected some value (it hasnt changed yet)
My SOHO: http://www.contactopuro.com.ar
-
Jun 1, 2007, 12:48 #4
- Join Date
- Feb 2003
- Location
- Knoxville, TN
- Posts
- 531
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
maybe something like this...
javascript
Code:window.onload = function() { changeText(document.getElementById("part")); }
Code:<select name="part" id="part" class="input_text" onchange="changeText(this);"> <option value="1"> Motor </option> <option value="2"> Steel </option> <option value="3"> Glass </option> </select>
-
Jun 1, 2007, 14:10 #5
- Join Date
- Jun 2002
- Location
- Buenos Aires, Argentina
- Posts
- 361
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Where should I place the javascript?
My SOHO: http://www.contactopuro.com.ar
Bookmarks