<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: HTML form within notebooks in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/html-form-within-notebooks/m-p/111233#M43827</link>
    <description>&lt;P class=""&gt;You can use &lt;SPAN class=""&gt;&lt;STRONG&gt;Databricks widgets&lt;/STRONG&gt;&lt;/SPAN&gt; to create a form-like experience and capture user input dynamically.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;dbutils.widgets.text("catalog", "", "Enter Catalog Name")
dbutils.widgets.text("schema", "", "Enter Schema Name")
dbutils.widgets.text("table", "", "Enter Table Name")

catalog = dbutils.widgets.get("catalog")
schema = dbutils.widgets.get("schema")
table = dbutils.widgets.get("table")

query = f"SELECT * FROM {catalog}.{schema}.{table} LIMIT 10"

display(spark.sql(query))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="StefanKoch_0-1740549451050.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/15094i8230849B9CF38BBF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="StefanKoch_0-1740549451050.png" alt="StefanKoch_0-1740549451050.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 26 Feb 2025 06:00:17 GMT</pubDate>
    <dc:creator>Stefan-Koch</dc:creator>
    <dc:date>2025-02-26T06:00:17Z</dc:date>
    <item>
      <title>HTML form within notebooks</title>
      <link>https://community.databricks.com/t5/data-engineering/html-form-within-notebooks/m-p/110990#M43756</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I'm trying to make a small form in Databricks notebooks. I can't currently use apps so want an interim solution.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can successfully make the form using HTML which displays correctly but I cannot extract the values/use them e.g. A form with three text boxes, one for catalog, one for schema, one for table name. Upon submit, I would like it to show me the top ten rows from that table but currently I can't get that information to do the select function with.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have any ideas?&lt;/P&gt;</description>
      <pubDate>Sun, 23 Feb 2025 17:50:11 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/html-form-within-notebooks/m-p/110990#M43756</guid>
      <dc:creator>ConfusedZebra</dc:creator>
      <dc:date>2025-02-23T17:50:11Z</dc:date>
    </item>
    <item>
      <title>Re: HTML form within notebooks</title>
      <link>https://community.databricks.com/t5/data-engineering/html-form-within-notebooks/m-p/110993#M43757</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/136000"&gt;@ConfusedZebra&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;Could you please share your HTML form, how are you trying to extract the values out of it?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 23 Feb 2025 23:53:43 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/html-form-within-notebooks/m-p/110993#M43757</guid>
      <dc:creator>Alberto_Umana</dc:creator>
      <dc:date>2025-02-23T23:53:43Z</dc:date>
    </item>
    <item>
      <title>Re: HTML form within notebooks</title>
      <link>https://community.databricks.com/t5/data-engineering/html-form-within-notebooks/m-p/111233#M43827</link>
      <description>&lt;P class=""&gt;You can use &lt;SPAN class=""&gt;&lt;STRONG&gt;Databricks widgets&lt;/STRONG&gt;&lt;/SPAN&gt; to create a form-like experience and capture user input dynamically.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;dbutils.widgets.text("catalog", "", "Enter Catalog Name")
dbutils.widgets.text("schema", "", "Enter Schema Name")
dbutils.widgets.text("table", "", "Enter Table Name")

catalog = dbutils.widgets.get("catalog")
schema = dbutils.widgets.get("schema")
table = dbutils.widgets.get("table")

query = f"SELECT * FROM {catalog}.{schema}.{table} LIMIT 10"

display(spark.sql(query))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="StefanKoch_0-1740549451050.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/15094i8230849B9CF38BBF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="StefanKoch_0-1740549451050.png" alt="StefanKoch_0-1740549451050.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2025 06:00:17 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/html-form-within-notebooks/m-p/111233#M43827</guid>
      <dc:creator>Stefan-Koch</dc:creator>
      <dc:date>2025-02-26T06:00:17Z</dc:date>
    </item>
    <item>
      <title>Re: HTML form within notebooks</title>
      <link>https://community.databricks.com/t5/data-engineering/html-form-within-notebooks/m-p/111835#M44011</link>
      <description>&lt;P&gt;Thanks both.&amp;nbsp;&lt;BR /&gt;Notebooks are a little too intimidating for some users so we are trying to make them look and feel a bit more like what they are used to. Ideally we would build an app but apps aren't available in our area yet so we need an interim solution. All a user needs to do is add some test, pick a date and select a file. Widgets don't really give the date picker option nor the file browser option so aren't ideal.&lt;BR /&gt;&lt;BR /&gt;I've tried a few different options but no joy yet, tried:&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from IPython.display import HTML, display, Javascript
from IPython.core.display import display as core_display

# HTML form
html_form = """
&amp;lt;form id="myForm"&amp;gt;
    &amp;lt;label for="input_text"&amp;gt;Enter Text:&amp;lt;/label&amp;gt;&amp;lt;br&amp;gt;
    &amp;lt;input type="text" id="input_text" name="input_text"&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;
    
    &amp;lt;label for="input_date"&amp;gt;Enter Date:&amp;lt;/label&amp;gt;&amp;lt;br&amp;gt;
    &amp;lt;input type="date" id="input_date" name="input_date"&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;
    
    &amp;lt;label for="user_file"&amp;gt;Select File:&amp;lt;/label&amp;gt;&amp;lt;br&amp;gt;
    &amp;lt;input type="file" id="input_file" name="input_file"&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;
    
    &amp;lt;input type="button" value="Submit" onclick="submitForm()"&amp;gt;
&amp;lt;/form&amp;gt;

&amp;lt;div id="output"&amp;gt;&amp;lt;/div&amp;gt;

&amp;lt;script&amp;gt;
function submitForm() {
    var text = document.getElementById('input_text').value;
    var date = document.getElementById('input_date').value;
    var file = document.getElementById('input_file').value;
    
    var output = 'Form Submitted!&amp;lt;br&amp;gt;';
    output += 'Text entered: ' + text + '&amp;lt;br&amp;gt;';
    output += 'Date selected: ' + date + '&amp;lt;br&amp;gt;';
    output += 'File selected: ' + file.split('\\\\').pop().split('/').pop();
    
    document.getElementById('output').innerHTML = output;
    
    // Send data to Python
    IPython.notebook.kernel.execute('form_data = ' + JSON.stringify({text: text, date: date, file: file}));
}
&amp;lt;/script&amp;gt;
"""

# Display the HTML form
display(HTML(html_form))&lt;/LI-CODE&gt;&lt;P&gt;But this then doesn't do anything with the information so something like this is needed but it then requires a second button outside the form and/or fails&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def process_form_data():
    global form_data
    if 'form_data' in globals():
        print("Processed in Python:")
        print(f"Text entered: {form_data['text']}")
        print(f"Date selected: {form_data['date']}")
    else:
        print("No form data available yet. Please submit the form.")

# Create a button to process form data in Python
button = widgets.Button(description="Process in Python")
button.on_click(lambda _: process_form_data())
display(button)&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 05 Mar 2025 15:26:10 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/html-form-within-notebooks/m-p/111835#M44011</guid>
      <dc:creator>ConfusedZebra</dc:creator>
      <dc:date>2025-03-05T15:26:10Z</dc:date>
    </item>
  </channel>
</rss>

