4 Replies - 650 Views - Last Post: 30 April 2013 - 01:12 AM

#1 praveenit1990  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 24-April 13

Space Problem with .html

Posted 27 April 2013 - 12:36 AM

When I click on text box field im calling a javascript function which in turn will default the option value in select (fatcaSearchDO.bankId) . This is not working when I call javaCall() and option3 value is not setting

<html:select styleClass="login-textbox" name="FatcaSearchForm" property="fatcaSearchDO.bankId" onclick="checkRadio('2')" onfocus="checkRadio('2')" styleId="BankID" style="width=250">
                                                       
                                                <option value="Option1"> Option1</option>
                                                <option value="Option2"> Option2</option>
                                                <option value="Option3"> Option3</option>       
                                                                     
                                                              
                                                       </html:select>


<html:text name="FatcaSearchForm" styleClass="login-textbox" property="fatcaSearchDO.taxFormId"  maxlength="10" onclick=" javaCall ()" onfocus ="checkRadio('3')" />



Function javaCall(){
Var bankID=document.all(“fatcaSearchDO.bankId”);
bankID.value=’ Option3’;
}


This post has been edited by pbl: 27 April 2013 - 07:24 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Space Problem with .html

#2 andrewsw  Icon User is offline

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3333
  • View blog
  • Posts: 11,293
  • Joined: 12-December 12

Re: Space Problem with .html

Posted 27 April 2013 - 04:18 AM

You should avoid redundant spaces:

bankID.value="Option3";

onclick="javaCall()"

However, to select an option you'll need to loop through them:

NB Javascript is case-sensitive.

var bankID = document.all("fatcaSearchDO.bankId"); // I'm assuming this line works
for (var i, j = 0; i = bankID.options[j]; j++) {
    if (i.value == "Option3") {
        bankID.selectedIndex = j;
        break;
    }
}

It is possible to directly select the third option but doing it with a loop is more flexible.

BTW You should also be using a plain-text editor, not one that creates paired-quotes and apostrophes (smart quotes).
Was This Post Helpful? 0
  • +
  • -

#3 andrewsw  Icon User is offline

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3333
  • View blog
  • Posts: 11,293
  • Joined: 12-December 12

Re: Space Problem with .html

Posted 27 April 2013 - 04:32 AM

..and you should edit your post's title, it is useless for search purposes.
Was This Post Helpful? 0
  • +
  • -

#4 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2675
  • View blog
  • Posts: 11,305
  • Joined: 20-September 08

Re: Space Problem with .html

Posted 27 April 2013 - 08:51 AM

http://technojeeves....ipt-is-not-java
Was This Post Helpful? 1
  • +
  • -

#5 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3515
  • View blog
  • Posts: 10,143
  • Joined: 08-June 10

Re: Space Problem with .html

Posted 30 April 2013 - 01:12 AM

there are some errors in your JS (lines 12 beyond)
- Java​Script is case sensitive. Function =/= function
- strings are quoted with straight quotes (' and ") not with typographical ones. (you can see that from the missing string highlighting here)
- document.all() is proprietary IE 5 code. better not use it today as all browsers (even IE) support getElementById()
- though I’m not sure whether dots are allowed for ID values, you’d better not use them. it makes CSS selector expressions useless (. denotes a class in CSS)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1