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 4 of 4
  1. #1
    Regular Coder
    Join Date
    Sep 2008
    Posts
    116
    Thanks
    2
    Thanked 0 Times in 0 Posts

    problem in putting html code inside javascript

    I have the following html code snippet

    Code:
    <script type="text/javascript" language="javascript">
      
       function setdetails()
        {   
    	
    	 document.write('<form id="form1" action="http://210.212.144.227/rgtu_web/results2005/results.php" method="post">)
    	   <div id="details">
    	     <fieldset>
    	      <legend>Enter Your Details</legend>
    		  <a style="position:absolute;left:20px;top:50">Roll Number :</a>
    		  <input id="enrollNo" name="enrollNo" type="text">
    		  <a style="position:absolute;left:20px;top:100">Branch and Stream :</a>		
    		  <select id="select2" name="tableName">
              <option value="none">Please select your stream</option>
              <option value="be_2">BE 2nd Semester</option> <option value="be_3">BE 3rd Semester</option> 
    		  <option value="be_4">BE 4th Semester</option> <option value="be_5">BE 5th Semester</option> 
    		  <option value="be_6">BE 6th Semester</option> <option value="be_7">BE 7th Semester</option> 
    		  <option value="be_8">BE 8th Semester</option> <option value="barch_1">B Arch 1st Semester</option>
    		   <option value="barch_2">B Arch 2nd Semester</option> <option value="barch_3">B Arch 3rd Semester</option> 
    		   <option value="barch_4">B Arch 4th Semester</option> <option value="barch_5">B Arch 5th Semester</option> 
    		   <option value="barch_6">B Arch 6th Semester</option> <option value="barch_7">B Arch 7th Semester</option> 
    		   <option value="barch_8">B Arch 8th Semester</option> <option value="barch_9">B Arch 9th Semester</option> 
    		   <option value="barch_10">B Arch 10th Semester</option> <option value="bph_1">B Pharma 1st Semester</option>
    		   <option value="bph_2">B Pharma 2nd Semester</option> <option value="bph_3">B Pharma 3rd Semester</option> 
    		    <option value="bph_4">B Pharma 4th Semester</option> <option value="bph_5">B Pharma 5th Semester</option> 
    			<option value="bph_6">B Pharma 6th Semester</option> <option value="bph_7">B Pharma 7th Semester</option>
    			 <option value="bph_8">B Pharma 8th Semester</option> <option value="mca_1">MCA 1st Semester</option> 
    			 <option value="mca_2">MCA 2nd Semester</option> <option value="mca_3">MCA 3rd Semester</option>
    			  <option value="mca_4">MCA 4th Semester</option>
    			  <option value="mca_5">MCA 5th Semester</option> <option value="mca_6">MCA 6th Semester</option> <option value="pg_1">ME/M.Tech. I Semester</option> 
    			  <option value="pg_2">ME/M.Tech. II Semester</option> <option value="pg_3">ME/M.Tech. III Semester</option> <option value="pg_4">ME/M.Tech. IV &amp; VI Semester</option> 
    			  <option value="pg_5">ME/M.Tech. V Semester</option> <option value="mpy_1">M.Pharma I Semester</option> <option value="mpy_2">M.Pharma II Semester</option> <option value="mpy_3">M.Pharma III Semester</option> <option value="mpy_4">M.Pharma IV Semester</option> <option value="bept_1">BE PTDC I Semester</option> <option value="bept_2">BE PTDC II Semester</option> <option value="bept_3">BE PTDC III Semester</option> <option value="bept_4">BE PTDC IV Semester</option>
              </select>
    		  <input type="submit" value="Submit" style="position:absolute;left:362px;top:200px;width:108px;height:22px;background-image:url('http://www.stripathi.110mb.com/external/images/butt.jpg');"></input>
    	    </fieldset>	
    	   </div>  
         </form>')
    	} 
       </script>

    when I run this, there was an error
    well, i am not sure how to put this whole chunk of code inside single document.write() statement.

    thanks in advance

  • #2
    Senior Coder shyam's Avatar
    Join Date
    Jul 2005
    Posts
    1,563
    Thanks
    2
    Thanked 163 Times in 160 Posts
    javascript is not php...literal strings cannot span multiple lines...

    Code:
     document.write('<form id="form1" action="http://210.212.144.227/rgtu_web/results2005/results.php" method="post">)' + 
    	  ' <div id="details">' + 
    ...
    You never have to change anything you got up in the middle of the night to write. -- Saul Bellow

  • #3
    Regular Coder
    Join Date
    Sep 2008
    Posts
    116
    Thanks
    2
    Thanked 0 Times in 0 Posts
    ok...i did as you told

    but there is not any effect of style block defined in <head> section for the elements in side this script like...<div>, <select>, <input>

    where exactly should I put the style blocks for these elements?

  • #4
    Regular Coder
    Join Date
    Sep 2008
    Posts
    116
    Thanks
    2
    Thanked 0 Times in 0 Posts
    would anyone please explain it?


  •  

    Posting Permissions

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