Web Design Forums

Javascript, AJAX, and JSON

Having problems with Javascript? Need help picking a library? Post your questions here.

Referring to specific form element



Site of the Month Nominations
ENTER YOUR SITE NOW!

Reply
 
LinkBack Thread Tools
Old July 27 '05, 11:27 AM (#1)
AMulligan is offline
WDF Member
 
AMulligan's Avatar
 
Join Date: January 2005
Posts: 53
AMulligan is on a distinguished road
Referring to specific form element

Hello all,
I am having trouble. I don't know how to point to a specific element in a form, in an IF statement.
Code:
if(document.forms[0].elements[3].checked==true) { 
a = 1 
} 
else{
a = 0
}
if(document.forms[0].elements[4].checked==true) { 
b = 1 
} 
else{
b = 0
}
The form:
Code:
<form method="get" onsubmit="tester()">
1. Why did the chicken cross the road?
<p> 
<input type="radio" name="R1" value="val7">
a. Jacques Derrida: Any number of contending discourses may be discovered within the act of the chicken crossing the road, and each interpretation is equally valid as the authorial intent can never be discerned, because structuralism is DEAD, DAMMIT, DEAD!
</p>
<p> 
<input type="radio" name="R1" value="val8">
b. Salvador Dali: The Fish.
</p>
<p> 
<input type="radio" name="R1" value="val9">
c. Both A & B. </p>
2. How many Accountants does it take to change a light bulb?
<p> 
<input type="radio" name="R2" value="val4">
a. Both B &amp; C.</p>
<p> 
<input type="radio" name="R2" value="val5">
b. None-just assume it's changed.</p>
<p> 
<input type="radio" name="R2" value="val6">
c. What sort of answer did you have in mind?</p>
<input type="submit" value="Submit">
  </form>
Now for some reason the element[number] does not alway correspond the the actual placement in the form. What I want to do is to uniquely specific the element so there is no chance of error. Hopefully I have explained myself sufficiently.
Any ideas?
Thank you.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old August 2 '05, 05:27 PM (#2)
Ravenn is offline
New Member!
 
Ravenn's Avatar
 
Join Date: July 2005
Posts: 18
Ravenn is on a distinguished road
Send a message via ICQ to Ravenn Send a message via MSN to Ravenn
<elementtagname id="mycoolelemnt"

var myCoolElement = document.getElementById('mycoolelement')....
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

  Web Design Forums » Programming Help » Javascript, AJAX, and JSON

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


 
User Infomation
Your Avatar

Site Of The Month

Ticket Cake
Ticket Cake

Ticket Cake is a drupal based event ticketing platform. It features that ability to browse events and share them.

Nominate Your Site Now!

Advertisement
WolfCMS.org

Latest Articles
- by RickM
- by bfsog

Advertisement

Partner Links



All times are GMT -4. The time now is 02:57 AM.


WebDesignForums.net is Copyright © 2010 RikeMedia.

SEO by vBSEO

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163