<?xml version="1.0" encoding="utf-8" ?><rss version="2.0" xml:base="https://www.webmaster-forums.net/crss/node/1049421" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title></title>
    <link>https://www.webmaster-forums.net/crss/node/1049421</link>
    <description></description>
    <language>en</language>
          <item>
    <title>Note - The getElementsByName</title>
    <link>https://www.webmaster-forums.net/html-css-and-javascript/repetitive-code#comment-1263545</link>
    <description> &lt;p&gt;Note - The getElementsByName method works differently in different browsers.&lt;/p&gt;
&lt;p&gt;In Internet Explorer and Opera, it searches and returns the elements matched by id and name attributes.&lt;br /&gt;
In Firefox, Google Chrome and Safari, only elements with matching name attributes are returned.&lt;/p&gt;
&lt;p&gt;- Another difference is case-sensitivity. &lt;/p&gt;
&lt;p&gt;In Firefox, Opera, Google Chrome and Safari, the getElementsByName method is case-sensitive for the value of the name (and the id in Opera) attribute.&lt;br /&gt;
In Internet Explorer, it is not case-sensitive for the value of the id and name attributes.&lt;/p&gt;
 </description>
     <pubDate>Tue, 05 Apr 2011 04:26:36 +0000</pubDate>
 <dc:creator>webwiz</dc:creator>
 <guid isPermaLink="false">comment 1263545 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>I finally solved the problem</title>
    <link>https://www.webmaster-forums.net/html-css-and-javascript/repetitive-code#comment-1263494</link>
    <description> &lt;p&gt;I finally solved the problem with getElementsByName, but thank you.&lt;br /&gt;
&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;function valAdd()&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var e=document.getElementsByName(&amp;quot;addpts&amp;quot;);&lt;br /&gt;&lt;br /&gt; for(var i=0;i&amp;lt;e.length;i++){e[i].value = Number(e[i].value) + Number(1);}&lt;br /&gt;}&lt;br /&gt;function valSubtract()&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var e=document.getElementsByName(&amp;quot;addpts&amp;quot;);&lt;br /&gt;&lt;br /&gt; for(var i=0;i&amp;lt;e.length;i++){e[i].value = Number(e[i].value) - Number(1);}&lt;br /&gt;}&lt;/code&gt;&lt;/div&gt;&lt;br /&gt;
&quot;addpts&quot; is the field I was trying to change in each form. The only problem is that it changes the addpts field in all forms instead of the particular form I&#039;m trying to tweak. It still works though.&lt;/p&gt;
 </description>
     <pubDate>Mon, 04 Apr 2011 03:00:51 +0000</pubDate>
 <dc:creator>AustInsane</dc:creator>
 <guid isPermaLink="false">comment 1263494 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>You could create a function</title>
    <link>https://www.webmaster-forums.net/html-css-and-javascript/repetitive-code#comment-1263493</link>
    <description> &lt;p&gt;You could create a function that takes the amount to adjust by and the form id number:&lt;br /&gt;
&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;function changePtsOnForm(amount, form_id){&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var form_field = document[&amp;#039;myForm&amp;#039; + form_id].addpts;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; form_field.value = Number(form_field.value) + amount;&lt;br /&gt;}&lt;/code&gt;&lt;/div&gt;&lt;br /&gt;
Then you can call it like:&lt;br /&gt;
&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;changePtsOnForm(1, 1); &lt;br /&gt;changePtsOnForm(-1, 1);&lt;/code&gt;&lt;/div&gt;&lt;br /&gt;
If you posted some of your HTML (where these JavaScript functions are called), I could probably simplify the code even more.&lt;/p&gt;
 </description>
     <pubDate>Mon, 04 Apr 2011 02:40:00 +0000</pubDate>
 <dc:creator>teammatt3</dc:creator>
 <guid isPermaLink="false">comment 1263493 at https://www.webmaster-forums.net</guid>
  </item>
  </channel>
</rss>
