javascript return true or false

Discussion in 'Javascript' started by rkapur12@gmail.com, Jul 7, 2005.

  1. Guest

    In my jsp code I have an image which if someone clicks on that it
    stores data like "string1" in the hidden field that I have defined on
    page as:

    <html:hidden property="selectedOfficeType" value="" />

    later when I click save button (with the following code:)

    <input id="saveButtonId" type="button" value="Save"
    onclick="javascript:save('counter')" class="mainBody"/></td>

    this calls a method defined in javascript like this:

    function save(counter){
    func1(arg0)
    document.form.submit();
    }

    function func1(arg0){
    func2(arg1)
    }

    function func2(arg1){
    line1
    line2
    line3
    }

    if I put alert in save method like alert("selectedOfficeType:
    "+selectedOfficeType) Then it alerts "string1" as expected; if I put
    alert in func1, I get "string1" and if I put alert in funct2 before
    line1 or before line 2 I get the value "string1"

    But the problem is that for some reason I don't get it (alert prints
    undefined) after line2 or before line 3 and there after if I put alert
    back in save method after making calling to func2 I get "undefined" as
    the value.
    Even if I comment out line 2 and line 3, it still prints out as
    undefined. For some reason the value returned by alert in the begining
    of the func2 is fine but towards the middle of the method it starts
    alerting me "undefined" and thereafter back in save method it alerts
    "undefined".

    Could someone please help me with this; thank you so much.
    -raj.
    , Jul 7, 2005
    #1
    1. Advertising

  2. ASM Guest

    wrote:
    > For some reason the value returned by alert in the begining
    > of the func2 is fine but towards the middle of the method it starts
    > alerting me "undefined" and thereafter back in save method it alerts
    > "undefined".


    if anything wrong in line 2 or 3 that would have to work

    it does work with that :

    <html>
    <script type="text/javascript">
    function save(counter){
    var arg0;
    func1(arg0)
    document.forms[0].submit();
    }
    function func1(arg0){
    func2(arg0)
    }
    function func2(arg1){
    line1=''
    line2=''
    line3=''
    say();
    }
    function say(){
    msg = document.forms[0].selectedOfficeType.value;
    alert('selectedOfficeType = '+msg);
    }
    </script>
    <form action="test.html" target="_blank">
    <input type="button"
    onclick="selectedOfficeType.value='string_1';"
    value="fill hidden">
    <input type="button" value="Save"
    onclick="save('counter')" />
    <input type="button"
    onclick="selectedOfficeType.value='';"
    value="empty hidden">
    <input type="hidden" name="selectedOfficeType" value="" />
    </form>
    </html>



    --
    Stephane Moriaux et son [moins] vieux Mac
    ASM, Jul 7, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Siemel Naran

    Does true ^ true return false?

    Siemel Naran, Jun 17, 2004, in forum: C++
    Replies:
    19
    Views:
    643
    Chris Theis
    Jun 18, 2004
  2. Pierre Quentel

    "0 in [True,False]" returns True

    Pierre Quentel, Dec 12, 2005, in forum: Python
    Replies:
    59
    Views:
    1,004
    Grant Edwards
    Dec 16, 2005
  3. André
    Replies:
    3
    Views:
    1,552
  4. bdb112
    Replies:
    45
    Views:
    1,293
    jazbees
    Apr 29, 2009
  5. w i l l
    Replies:
    4
    Views:
    226
    Dan Brussee
    Jul 4, 2003
Loading...

Share This Page