Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

show form value in alert after click on button

I am very new on HTML. I just trying to accept form value and want to show this value
in Alert. I try following code but it didn't help me...
I know this is very easy question but i am newbie on HTML,JavaScript. I search but didn't find relative to my requirement.... Javascript function....

  function updateTxt(field1,field2)
  {  
    var field1 = document.getElementById(field1);  
    var field2 = document.getElementById(field2);  
    alert(field1,field2);

    }  

HTML form

<input name="textfield" type="text" id="textfield" value="Search by keyword" class="search_input" >
<select name="select" id="select" class="input_list" >
          <option>Search jobs by category</option>
          <option>Business Sales Leadership Development Program</option>
          <option>Business Sales Solutions</option>
          <option>CTO</option>
          <option>Call Center</option></select>
 <input name="button" type="button" class="btn" value="Go" onClick="updateTxt(select,textfield)">

Please give me hint or direct me where i wrong...
Thanks in Advance

like image 702
Sandip Armal Patil Avatar asked Dec 27 '22 18:12

Sandip Armal Patil


1 Answers

change this code

<input name="button" type="button" class="btn" value="Go" onclick="updateTxt()">

and also this

     function updateTxt()
  {  
    var field1 = document.getElementById('textfield').value;  
    var field2 = document.getElementById('select').options[document.getElementById('select').selectedIndex].value;  
    alert(field1+'&'+field2);

    }  
like image 57
Naresh Tank Avatar answered Dec 29 '22 07:12

Naresh Tank