Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    New Coder
    Join Date
    Oct 2007
    Posts
    91
    Thanks
    2
    Thanked 0 Times in 0 Posts

    How to get Return values from Javascript to HTML.

    Hi,
    I've a Javascript function where i'm sending an return value. How do i capture this return value from HTML.

    My javascript func is as below:

    Code:
    function check()
    {
    var frm=document.forms.stream_selection
    sel_num = new Array();
    Parr = new Array();
    for(j=1;j<1000;j++)
    {
    	if(frm[j] != null)
    	{
    	  if(!frm[j].checked)
    	  {
    	      frm[0].checked=false
    	  }
    	  else
    	  {
    		Parr.push(j);
    		ParrStr=Parr.join(','); 
    		alert(Parr);
    	  }
      }
      
    }
    return(ParrStr);
    }
    My HTML call function is as below:

    Code:
    echo "<td><center><input name=\"sstreamname\" type=\"checkbox\" onclick=\"check():return true;\"></center></td></tr></font></center></tr></font></center>";
    How do i get the value of ParrStr and transfer this to next form. I'm using PHP .

    Thanks,
    Ramki.

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,865
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    If you have a form, put a hidden input element and assign the value it in the function.
    Code:
    ..............
    document.getrElementById('ParrStr').value=ParrStr;
    //return(ParrStr);
    }
    Code:
    <input type="hidden" name="ParrStr" id="ParrStr"/>
    . Now when you submit your page the value would be available and can be obtained through PHP
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New Coder
    Join Date
    Oct 2007
    Posts
    91
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by abduraooft View Post
    If you have a form, put a hidden input element and assign the value it in the function.
    Code:
    ..............
    document.getrElementById('ParrStr').value=ParrStr;
    //return(ParrStr);
    }
    Code:
    <input type="hidden" name="ParrStr" id="ParrStr"/>
    . Now when you submit your page the value would be available and can be obtained through PHP

    I did what you said and was trying to access it it next page using REQUEST as below:

    Code:
    $Parr_Str=$_REQUEST["ParrStr"];
    $sel_num=split(",", $Parr_Str);
    $i=0;
    while ($i < count($sel_num)) 
    {
       echo "Yup";
       echo "$sel_num[$i]<br>";
       $i++;
    }
    I'm able to see only Yup on screen. and i'm unable to see the values of ParrStr. the page is blank! Any help?

    Regards,
    Ramki.
    Last edited by ramki067; 02-25-2008 at 04:51 AM.

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,865
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    Have you used a form submit? Depending on the method="post" or ="get", you will get the value through $_POST['ParrStr'] or $_GET['ParrStr']
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #5
    New Coder
    Join Date
    Oct 2007
    Posts
    91
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by abduraooft View Post
    Have you used a form submit? Depending on the method="post" or ="get", you will get the value through $_POST['ParrStr'] or $_GET['ParrStr']
    I'm using,

    Code:
    <form name="stream_selection" enctype="multipart/form-data" method="post" action="selected_streams.php">
    and accessing it via $_REQUEST in the next page. Tried even with $_POST but with with the same result, Can't able to see.

    and submit button in the previous form is as below:

    Code:
    <INPUT type="submit" value="Submit" >
    Ramki.

  • #6
    New Coder
    Join Date
    Oct 2007
    Posts
    91
    Thanks
    2
    Thanked 0 Times in 0 Posts
    The page is giving me an error of

    Object doen't support this property or method for the below line.

    Code:
    document.getrElementById('ParrStr').value=ParrStr;
    Whats this error?

    Thanks,
    Ramki.

  • #7
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,298
    Thanks
    203
    Thanked 2,561 Times in 2,539 Posts
    Quote Originally Posted by ramki067 View Post
    The page is giving me an error of

    Object doen't support this property or method for the below line.

    Code:
    document.getrElementById('ParrStr').value=ParrStr;
    Whats this error?

    Thanks,
    Ramki.
    document.getrElementById('ParrStr').value=ParrStr;

  • #8
    New to the CF scene
    Join Date
    Feb 2011
    Location
    Dhaka,Bangladesh
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I want to get value a from when i click a button.How can i coding this.
    i code this
    function validateForm()
    {
    var emailID=document.getElementById("email").innerHTML;
    }

    <input name="email_id" type="text" size="30" value="Enter Your E-mail" onfocus="if(this.value=='Enter Your E-mail'){this.value=''};" onblur="if(this.value==''){this.value='Enter Your E-mail'};" id="email" />
    <input type="button" id="submit_button" value="Submit" size="80" onclick="validateForm()"/>


    But not work can any body help me ASAP.
    Last edited by runopu; 03-18-2011 at 10:37 AM.

  • #9
    Banned
    Join Date
    Feb 2011
    Posts
    2,699
    Thanks
    13
    Thanked 395 Times in 395 Posts
    try changing .innerHTML to .value


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •